CJE study materials
CJE study resources

CJE: Artifacts, Testing, and Plugin Ecosystem

CJE · Work through your exam, one topic at a time.

All guide sections

Artifacts, Testing, and Plugin Ecosystem

What this domain covers

What a build leaves behind, how test results change build status, and how to keep a plugin set healthy. Questions are practical: which step, which path, which status.

Core rules

  • Artifacts versus stashes. archiveArtifacts artifacts: 'target/*.jar', fingerprint: true, allowEmptyArchive: false copies files out of the workspace into $JENKINS_HOME/jobs/<job>/builds/<n>/archive and exposes them in the UI; they survive workspace cleanup and are deleted only by the build discarder. stash is temporary storage for moving files between stages and disappears when the run ends.
  • Fingerprints record a hash of the artifact plus which builds produced and consumed it, enabling traceability; they are off unless you request them.
  • Test results. junit '**/target/surefire-reports/*.xml' parses JUnit XML and marks the build UNSTABLE when tests fail. In declarative, use post { always { junit '**/reports/*.xml' } }. Options include allowEmptyResults, keepLongStdio, skipPublishingChecks.
  • Other publishers: publishHTML for HTML reports, recordIssues/warnings-ng for compiler and static-analysis findings, JaCoCo or Cobertura for coverage, and the Copy Artifact step to pull outputs from an upstream build.
  • Status ladder: SUCCESS → UNSTABLE → FAILURE → ABORTED/NOT_BUILT. Many publishers produce UNSTABLE rather than FAILURE, so downstream threshold settings must match reality.
  • Plugin mechanics. Plugins ship as .hpi/.jpi and declare dependencies, which are installed automatically. Manage Jenkins → Plugins has Available, Installed, and Advanced tabs; a restart is needed to load new plugin files; disabling a plugin leaves a .disabled marker in $JENKINS_HOME/plugins. Version drift is controlled by pinning in image builds, e.g. jenkins-plugin-cli --plugins git:5.2.0.

Worked example

A job exits 0 but shows yellow. Reasoning: compilation succeeded, yet junit parsed failing test XML and set the result to UNSTABLE. If policy says any test failure fails a release, add a step that promotes the result, e.g. set currentBuild.result = 'FAILURE' when the result is UNSTABLE, rather than relying on the exit code.

Traps

Archiving an absolute path or a workspace-relative path that does not exist, which is silently empty unless allowEmptyArchive is false; assuming artifacts outlive a discarder that drops the build; expecting junit to fail a build; installing plugin updates without reading the compatibility warning; letting an unpinned plugin set drift between environments.