0
0
Jenkinsdevops~20 mins

Copying artifacts between jobs in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Artifact Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Jenkins pipeline snippet?

Consider this Jenkins pipeline stage that copies artifacts from a previous job named BuildJob:

stage('Copy Artifacts') {
  steps {
    copyArtifacts(projectName: 'BuildJob', selector: lastSuccessful())
  }
}

What happens when this stage runs?

Jenkins
stage('Copy Artifacts') {
  steps {
    copyArtifacts(projectName: 'BuildJob', selector: lastSuccessful())
  }
}
ACopies artifacts from the last successful build of 'BuildJob' into the current workspace.
BTriggers 'BuildJob' to run and copies its artifacts immediately.
CCopies artifacts from the current job to 'BuildJob'.
DFails because 'copyArtifacts' requires a build number, not a selector.
Attempts:
2 left
💡 Hint

Think about what lastSuccessful() means in Jenkins.

Configuration
intermediate
2:00remaining
Which Jenkinsfile snippet correctly copies artifacts from a specific build number?

You want to copy artifacts from build number 42 of the job named TestJob. Which snippet does this correctly?

AcopyArtifacts(projectName: 'TestJob', selector: build('42'))
BcopyArtifacts(projectName: 'TestJob', buildNumber: 42)
CcopyArtifacts(projectName: 'TestJob', selector: specific('42'))
DcopyArtifacts(projectName: 'TestJob', selector: specificBuild(42))
Attempts:
2 left
💡 Hint

Look for the correct selector method for a specific build number.

Troubleshoot
advanced
2:00remaining
Why does this Jenkins pipeline fail to copy artifacts?

Given this pipeline snippet:

stage('Copy') {
  steps {
    copyArtifacts(projectName: 'NonExistentJob', selector: lastSuccessful())
  }
}

The pipeline fails with an error about missing artifacts. What is the most likely cause?

AThe job 'NonExistentJob' does not exist or has no successful builds.
BThe <code>copyArtifacts</code> step requires a build number, not a selector.
CThe pipeline workspace is not writable.
DThe <code>copyArtifacts</code> plugin is not installed.
Attempts:
2 left
💡 Hint

Check if the source job exists and has successful builds.

🔀 Workflow
advanced
2:30remaining
What is the correct order to copy artifacts between jobs in a multi-stage pipeline?

Arrange these steps in the correct order to copy artifacts from a build stage to a deploy stage within the same pipeline:

A4,2,1,3
B1,4,2,3
C2,1,4,3
D4,1,2,3
Attempts:
2 left
💡 Hint

Think about preparing workspace, building, copying, then deploying.

Best Practice
expert
2:00remaining
Which practice ensures reliable artifact copying between Jenkins jobs?

Choose the best practice to avoid failures when copying artifacts between jobs in Jenkins pipelines.

ACopy artifacts without specifying a build selector to get the latest.
BAlways archive artifacts in the source job before copying them.
CUse workspace sharing instead of artifact copying.
DDisable artifact archiving to speed up the pipeline.
Attempts:
2 left
💡 Hint

Think about what makes artifacts available for copying.