Challenge - 5 Problems
Pull Request Build Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Jenkinsfile snippet output for pull request build trigger
Given this Jenkinsfile snippet, what will be the output when a pull request is created?
pipeline {
agent any
triggers {
githubPullRequest()
}
stages {
stage('Build') {
steps {
echo "Building PR #${env.CHANGE_ID}"
}
}
}
}Jenkins
pipeline {
agent any
triggers {
githubPullRequest()
}
stages {
stage('Build') {
steps {
echo "Building PR #${env.CHANGE_ID}"
}
}
}
}Attempts:
2 left
💡 Hint
The environment variable CHANGE_ID contains the pull request number during PR builds.
✗ Incorrect
The githubPullRequest trigger sets environment variables like CHANGE_ID to the PR number. The echo prints this number.
❓ Configuration
intermediate2:00remaining
Correct Jenkinsfile stage condition for PR builds
Which Jenkinsfile stage condition correctly runs the stage only for pull request builds?
Attempts:
2 left
💡 Hint
Use the built-in condition to detect pull request builds.
✗ Incorrect
The 'changeRequest()' condition runs the stage only if the build is triggered by a pull request.
❓ Troubleshoot
advanced2:00remaining
Why does the Jenkins pull request build not trigger?
A Jenkins pipeline with 'githubPullRequest()' trigger does not start when a pull request is created. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if GitHub is notifying Jenkins about pull request events.
✗ Incorrect
The 'githubPullRequest()' trigger relies on GitHub webhooks to notify Jenkins of PR events. Without the webhook, builds won't start.
🔀 Workflow
advanced2:00remaining
Order of steps in a Jenkins pull request build workflow
Arrange the steps in the correct order for a Jenkins pipeline triggered by a pull request.
Attempts:
2 left
💡 Hint
Think about event flow from GitHub to Jenkins and back.
✗ Incorrect
GitHub sends the event first, Jenkins triggers the pipeline, pipeline runs stages, then results are reported back.
✅ Best Practice
expert2:00remaining
Best practice for securing Jenkins pull request builds
Which practice best secures Jenkins pull request builds against malicious code in PRs?
Attempts:
2 left
💡 Hint
Think about isolating untrusted code.
✗ Incorrect
Running PR builds in isolated containers limits damage from malicious code and protects the Jenkins environment.