0
0
Jenkinsdevops~10 mins

Pull request builds in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to trigger a build on pull request creation.

Jenkins
pipeline {
  agent any
  triggers {
    [1] {
      orgWhitelist('github.com')
    }
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building pull request...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
ApollSCM
Bupstream
Ccron
DgithubPullRequest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pollSCM' triggers builds on SCM changes but not specifically on pull requests.
Using 'cron' triggers builds on a schedule, not on pull requests.
2fill in blank
medium

Complete the code to specify the branch source for the pull request build.

Jenkins
pipeline {
  agent any
  triggers {
    githubPullRequest {
      [1] 'origin'
    }
  }
  stages {
    stage('Test') {
      steps {
        echo 'Testing pull request branch...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AbranchFilter
BorgWhitelist
CbranchSource
DtriggerPhrase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'orgWhitelist' filters organizations, not branches.
Using 'triggerPhrase' is for manual trigger phrases, not branch filtering.
3fill in blank
hard

Fix the error in the pull request build trigger configuration.

Jenkins
pipeline {
  agent any
  triggers {
    githubPullRequest {
      orgWhitelist('github.com')
      [1] 'master'
    }
  }
  stages {
    stage('Deploy') {
      steps {
        echo 'Deploying pull request...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AbranchFilter
Bbranch
CbranchName
DbranchSource
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'branch' instead of 'branchFilter' causes syntax errors.
Using 'branchName' is not recognized in this context.
4fill in blank
hard

Fill both blanks to configure the pull request trigger with a whitelist and a trigger phrase.

Jenkins
pipeline {
  agent any
  triggers {
    githubPullRequest {
      [1]('github.com')
      [2]('OK to test')
    }
  }
  stages {
    stage('Verify') {
      steps {
        echo 'Verifying pull request...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AorgWhitelist
BtriggerPhrase
CbranchFilter
Dcron
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cron' instead of 'triggerPhrase' for manual trigger comments.
Confusing 'branchFilter' with organization whitelist.
5fill in blank
hard

Fill all three blanks to create a pull request build that filters branches, uses a whitelist, and triggers on a phrase.

Jenkins
pipeline {
  agent any
  triggers {
    githubPullRequest {
      [1]('origin/develop')
      [2]('my-org')
      [3]('run tests')
    }
  }
  stages {
    stage('Build and Test') {
      steps {
        echo 'Building and testing pull request...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AbranchFilter
BorgWhitelist
CtriggerPhrase
Dcron
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cron' in place of 'triggerPhrase' causes builds to run on schedule, not on pull requests.
Mixing up 'orgWhitelist' and 'branchFilter' option names.