fix(ci): preserve failed test and coverage artifacts
This commit is contained in:
Vendored
+5
-1
@@ -40,6 +40,7 @@ pipeline {
|
|||||||
// Isolate publishers so a failed publisher does not suppress the other diagnostics.
|
// Isolate publishers so a failed publisher does not suppress the other diagnostics.
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
junit testResults: '**/build/test-results/test/TEST-*.xml',
|
junit testResults: '**/build/test-results/test/TEST-*.xml',
|
||||||
|
checksName: 'Test / Tests and coverage',
|
||||||
allowEmptyResults: env.VERIFICATION_SUCCEEDED != 'true'
|
allowEmptyResults: env.VERIFICATION_SUCCEEDED != 'true'
|
||||||
if (env.VERIFICATION_SUCCEEDED == 'true' && !fileExists('prometeu-packer/prometeu-packer-v1/build/test-results/test/TEST-p.packer.services.PackerAssetContractTest.xml')) {
|
if (env.VERIFICATION_SUCCEEDED == 'true' && !fileExists('prometeu-packer/prometeu-packer-v1/build/test-results/test/TEST-p.packer.services.PackerAssetContractTest.xml')) {
|
||||||
error 'Successful verification is missing the packer contract test report.'
|
error 'Successful verification is missing the packer contract test report.'
|
||||||
@@ -52,6 +53,8 @@ pipeline {
|
|||||||
id: 'jacoco',
|
id: 'jacoco',
|
||||||
name: 'JaCoCo Coverage',
|
name: 'JaCoCo Coverage',
|
||||||
checksName: 'JaCoCo Coverage',
|
checksName: 'JaCoCo Coverage',
|
||||||
|
enabledForFailure: true,
|
||||||
|
failOnError: true,
|
||||||
sourceDirectories: [[path: 'glob:**/src/main/java']],
|
sourceDirectories: [[path: 'glob:**/src/main/java']],
|
||||||
sourceCodeEncoding: 'UTF-8',
|
sourceCodeEncoding: 'UTF-8',
|
||||||
sourceCodeRetention: 'EVERY_BUILD',
|
sourceCodeRetention: 'EVERY_BUILD',
|
||||||
@@ -79,7 +82,8 @@ pipeline {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
archiveArtifacts artifacts: '**/build/test-results/test/**, **/build/reports/tests/test/**, **/build/reports/jacoco/**',
|
// Keep raw coverage data even when report generation fails.
|
||||||
|
archiveArtifacts artifacts: '**/build/test-results/test/**, **/build/reports/tests/test/**, **/build/reports/jacoco/**, **/build/jacoco/*.exec',
|
||||||
allowEmptyArchive: env.VERIFICATION_SUCCEEDED != 'true',
|
allowEmptyArchive: env.VERIFICATION_SUCCEEDED != 'true',
|
||||||
onlyIfSuccessful: false
|
onlyIfSuccessful: false
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-1
@@ -32,6 +32,21 @@ HTML and archived test/coverage reports after a failed verification command.
|
|||||||
Each publisher is isolated so one publisher error does not prevent the others
|
Each publisher is isolated so one publisher error does not prevent the others
|
||||||
from being attempted. The build console retains compilation/setup diagnostics.
|
from being attempted. The build console retains compilation/setup diagnostics.
|
||||||
|
|
||||||
|
JUnit explicitly completes the `Test / Tests and coverage` check from the post
|
||||||
|
block. Its name must match the check required by Gitea, independently of the
|
||||||
|
publisher's stage context. The separate coverage check remains `JaCoCo Coverage`.
|
||||||
|
|
||||||
|
Coverage recording is enabled for failed builds so available coverage can still
|
||||||
|
be inspected after test failures. Coverage processing errors fail publication;
|
||||||
|
the isolated HTML and artifact publishers are still attempted. Archiving runs
|
||||||
|
even for failed or unstable builds and retains the original JUnit XML/binary
|
||||||
|
results, test HTML, coverage XML/HTML, and raw `**/build/jacoco/*.exec` files.
|
||||||
|
JUnit XML includes test failure details and captured output; the raw JaCoCo data
|
||||||
|
is retained even if consolidated XML/HTML generation fails. If no coverage data
|
||||||
|
was produced, there is no coverage artifact to recover; inspect the build console
|
||||||
|
and any available test results. Artifacts follow the Jenkins job's build/artifact
|
||||||
|
retention policy.
|
||||||
|
|
||||||
An otherwise successful verification must produce JUnit results, the packer
|
An otherwise successful verification must produce JUnit results, the packer
|
||||||
contract suite report, consolidated JaCoCo XML and HTML. Missing successful-build
|
contract suite report, consolidated JaCoCo XML and HTML. Missing successful-build
|
||||||
evidence fails publication. A failed compilation may have no reports: the
|
evidence fails publication. A failed compilation may have no reports: the
|
||||||
@@ -54,4 +69,7 @@ A Jenkins run is needed to observe actual report publication and coverage checks
|
|||||||
report any unavailable controller validation explicitly.
|
report any unavailable controller validation explicitly.
|
||||||
|
|
||||||
Jenkins behavior references: [post conditions](https://www.jenkins.io/doc/book/pipeline/syntax/#post)
|
Jenkins behavior references: [post conditions](https://www.jenkins.io/doc/book/pipeline/syntax/#post)
|
||||||
and [catchError](https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#catcherror-catch-error-and-set-build-result-to-failure).
|
and [catchError](https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#catcherror-catch-error-and-set-build-result-to-failure),
|
||||||
|
[JUnit check names](https://www.jenkins.io/doc/pipeline/steps/junit/),
|
||||||
|
[coverage recording on failed builds](https://www.jenkins.io/doc/pipeline/steps/coverage/),
|
||||||
|
and [artifact archiving](https://www.jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-artifacts).
|
||||||
|
|||||||
Reference in New Issue
Block a user