Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins pipeline build github pull request

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 ?

like image 948
Anthony Dubuissez Avatar asked Jul 05 '16 08:07

Anthony Dubuissez


1 Answers

Use

checkout scm

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

like image 157
Jesse Glick Avatar answered Oct 23 '22 10:10

Jesse Glick