Jenkins pipeline construction

given that I am using the pipeline plugin + the entire github plugin is installed in jenkins, I struggled to check the current pull request, which caused the job in the pipeline script as follows:

#!groovy

 node('master') {
       stage 'Checkout'

 checkout changelog: true, poll: true, scm: [$class: 'GitSCM', branches: [[name: "origin/????"]], doGenerateSubmoduleConfigurations: false, submoduleCfg: [], userRemoteConfigs: [[name: 'origin', url: 'git@github.com/project.git', credentialsId: 'github-id']]]

 }

but I did not find a way to get the current request request branch from any env variable, maybe this is not the case to check the branch called?

+4
source share
1 answer

Using

checkout scm

This is not just a syntactic simplification; it ensures that the revision of the repository is verified exactly by itself Jenkinsfile.

+3
source

All Articles