I have a multi repo job and want to check out in one pipeline 2 branches ( 
1 from each repo ) 

>From repo A I Poll for a feature*  and then I want to attempt to build repo 
B with that same feature* or fallback to develop branch.

In the GUI job version I was using checkout to specific local branch with 
** which populated the GIT_LOCAL_BRANCH env variable. and hence repo B had 
alternative strategy checkout with 
GIT_LOCAL_BRANCH or develop. 

In the jenkinsfile pipeline
the env,GIT_LOCAL_BRANCH always returns null . 


I read online that this variable is only accessed for a multibranch 
pipeline ?

Is there no other way to get the git branch that  was just checked out so I 
can pass it to the resolve scm step ? 


Below is the jenkinsfile.

node {

  stage ('Stage CheckOut 1'){ 
   
//Repo A ( has Polling )    
 checkout([$class: 'GitSCM', branches: [[name: '*/feature**']], 
 doGenerateSubmoduleConfigurations: false, extensions: [[$class:
 'RelativeTargetDirectory', relativeTargetDir: 'android'], 
[$class:'LocalBranch', localBranch: '**']],
 submoduleCfg: [], userRemoteConfigs:
 [[credentialsId: '', url:
 'https://github.com/....git']]])

//Checking if similar branch name as repo A exists in repo B 
 def b  = resolveScm source: [$class: 'GitSCMSource', credentialsId: '',
 id: '_', remote: 'https://github.com/.....git', traits: [[$class: 
'jenkins.plugins.git.traits.BranchDiscoveryTrait']]],
 targets: [env. GIT_LOCAL_BRANCH, 'develop']
 checkout b
 
  }   
  }  

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b6d82bc9-9f55-443c-b188-8d73f973a1f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to