diff --git a/plugins/jenkins/src/api/index.ts b/plugins/jenkins/src/api/index.ts index 38f6f719c1..545a1da9cc 100644 --- a/plugins/jenkins/src/api/index.ts +++ b/plugins/jenkins/src/api/index.ts @@ -103,6 +103,32 @@ export class JenkinsApi { return results; } + private getTestReport( + jenkinsResult: any, + ): { + total: number; + passed: number; + skipped: number; + failed: number; + testUrl: string; + } { + return jenkinsResult.actions + .filter( + (action: any) => + action._class === 'hudson.tasks.junit.TestResultAction', + ) + .map((action: any) => { + return { + total: action.totalCount, + passed: action.totalCount - action.failCount - action.skipCount, + skipped: action.skipCount, + failed: action.failCount, + testUrl: `${jenkinsResult.url}${action.urlName}/`, + }; + }) + .pop(); + } + mapJenkinsBuildToCITable( jenkinsResult: any, jobScmInfo?: any, @@ -142,6 +168,7 @@ export class JenkinsApi { return this.retry(jobName); }, source: source, + tests: this.getTestReport(jenkinsResult), }; } diff --git a/plugins/jenkins/src/pages/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/pages/BuildsPage/lib/CITable/CITable.tsx index 90d8db616e..2edff01799 100644 --- a/plugins/jenkins/src/pages/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/pages/BuildsPage/lib/CITable/CITable.tsx @@ -44,6 +44,61 @@ export type CITableBuildInfo = { onRestartClick: () => void; }; +const FailCount = ({ count }: { count: number }): JSX.Element | null => { + if (count !== 0) { + return <>{count} failed>; + } + return null; +}; + +const SkippedCount = ({ count }: { count: number }): JSX.Element | null => { + if (count !== 0) { + return <>>; + } + return null; +}; + +const FailSkippedWidget = ({ + skipped, + failed, +}: { + skipped: number; + failed: number; +}): JSX.Element | null => { + if (skipped === 0 && failed === 0) { + return null; + } + + if (skipped !== 0 && failed !== 0) { + return ( + <> + {' '} + (, ) + > + ); + } + + if (failed !== 0) { + return ( + <> + {' '} + () + > + ); + } + + if (skipped !== 0) { + return ( + <> + {' '} + () + > + ); + } + + return null; +}; + const generatedColumns: TableColumn[] = [ { title: 'Build', @@ -78,6 +133,28 @@ const generatedColumns: TableColumn[] = [ ); }, }, + { + title: 'Tests', + render: (row: Partial) => { + return ( + <> + + {row.tests && ( + + {row.tests.passed} / {row.tests.total} passed + + + )} + + {!row.tests && 'n/a'} + + > + ); + }, + }, { title: 'Actions', render: (row: Partial) => (
+ {row.tests && ( + + {row.tests.passed} / {row.tests.total} passed + + + )} + + {!row.tests && 'n/a'} +