given that I use the pipeline plugin + all the github plugin are installed in jenkins, I'm struggled to checkout the current pull request that triggered the job in the pipeline script like this :
#!groovy
node('master') {
stage 'Checkout'
checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches: [[name: "origin/????"]], doGenerateSubmoduleConfigurations: false, submoduleCfg: [], userRemoteConfigs: [[name: 'origin', url: '[email protected]/project.git', credentialsId: 'github-id']]]
}
but I don't find any way to get the current pull request branch from any env variable, maybe it's not that way to checkout the triggered branch ?
Use
checkout scm
This is not just a syntactic simplification; it ensures that the repository revision checked out is exactly that of Jenkinsfile
itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With