Artifacts, fingerprints and test results

Jenkins CI/CD Course · lesson 8 of 15 · 5 min read

What the build produced and what the tests said are published deliberately, and they decide the build result.

Open this lesson in the learning hub

Key points

  • archiveArtifacts copies files out of the workspace into JENKINS_HOME so they outlive the next build.
  • Adding fingerprint: true records an MD5 per file, so Jenkins can show where that exact jar was used.
  • stash and unstash move files between stages or agents and are thrown away when the build ends.
  • The junit step parses the surefire XML and sets the build to UNSTABLE when any test failed.
  • Archiving without a buildDiscarder fills the controller disk and takes every job down with it.
  • A quality gate that only warns is not a gate - waitForQualityGate abortPipeline: true is.

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.