Artifacts, fingerprints and test results
What the build produced and what the tests said are published deliberately, and they decide the build result.
Open this lesson in the learning hubKey points
archiveArtifactscopies files out of the workspace intoJENKINS_HOMEso they outlive the next build.- Adding
fingerprint: truerecords an MD5 per file, so Jenkins can show where that exact jar was used. stashandunstashmove files between stages or agents and are thrown away when the build ends.- The
junitstep parses the surefire XML and sets the build to UNSTABLE when any test failed. - Archiving without a
buildDiscarderfills the controller disk and takes every job down with it. - A quality gate that only warns is not a gate -
waitForQualityGate abortPipeline: trueis.
Example
stage('Verify') {
steps {
sh 'mvn -B -ntp -Duser.home=/var/maven -Dmaven.test.failure.ignore=true verify'
}
post {
always {
junit '**/target/surefire-reports/*.xml'
archiveArtifacts artifacts: 'target/*.jar',
fingerprint: true,
onlyIfSuccessful: false
}
}
}
junit downgrades to UNSTABLE, a throwing step means FAILURE, and no step ever moves a result back up.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Jenkins CI/CD Course course, and every lesson in it is listed on the Jenkins CI/CD Course contents page.