Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gregswift/0238964d881b2a777e144d2d38b29adf to your computer and use it in GitHub Desktop.
Save gregswift/0238964d881b2a777e144d2d38b29adf to your computer and use it in GitHub Desktop.
janky jenkins PR pipeline hack
isPR = env.BRANCH_NAME ? env.BRANCH_NAME.startsWith("PR-") : false
if (isPR) {
checkout scm:[$class: 'GitSCM', userRemoteConfigs: [[ url: repoURL, credentialsId: gitCredentialId ]]]
sh "git fetch origin pull/'${numberPR}'/head:'${BRANCH_NAME}'"
sh "git checkout '${BRANCH_NAME}'"
} else {
checkout scm:[$class: 'GitSCM', userRemoteConfigs: [[ url: repoURL, credentialsId: gitCredentialId ]]]
sh 'git checkout master'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment