0
0
Jenkinsdevops~20 mins

Pull request builds in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pull Request Build Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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}"
      }
    }
  }
}
ABuild stage skipped
BBuilding PR #null
CBuilding PR #0
DBuilding PR #42
Attempts:
2 left
💡 Hint
The environment variable CHANGE_ID contains the pull request number during PR builds.
Configuration
intermediate
2:00remaining
Correct Jenkinsfile stage condition for PR builds
Which Jenkinsfile stage condition correctly runs the stage only for pull request builds?
Awhen { changeRequest() }
Bwhen { branch 'main' }
Cwhen { environment name: 'CHANGE_ID', value: '' }
Dwhen { not { changeRequest() } }
Attempts:
2 left
💡 Hint
Use the built-in condition to detect pull request builds.
Troubleshoot
advanced
2: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?
AGitHub webhook for pull requests is not configured or missing
BThe Jenkinsfile syntax is invalid
CThe Jenkins agent is offline
DThe repository has no branches
Attempts:
2 left
💡 Hint
Check if GitHub is notifying Jenkins about pull request events.
🔀 Workflow
advanced
2: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.
A1,3,2,4
B2,1,3,4
C1,2,3,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about event flow from GitHub to Jenkins and back.
Best Practice
expert
2:00remaining
Best practice for securing Jenkins pull request builds
Which practice best secures Jenkins pull request builds against malicious code in PRs?
ADisable pull request builds to avoid risk
BRun PR builds in isolated containers with limited permissions
CRun PR builds with full admin privileges
DAllow PR builds to run on the main Jenkins master node
Attempts:
2 left
💡 Hint
Think about isolating untrusted code.