On Wed, Sep 27, 2017 at 7:39 PM Leonidas Kanellopoulos <
[email protected]> wrote:
> 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 .
>
>
If you're using Jenkins 2.60 or newer, and the latest releases of the
pipeline plugins, then you can assign the return value of checkout to a
groovy variable and use that as a map to access the name of the branch.
def repoMap = checkout( /* your setup here */ )
then access the contents of repoMpa.
>
> 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
> <https://groups.google.com/d/msgid/jenkinsci-users/b6d82bc9-9f55-443c-b188-8d73f973a1f9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CAO49JtFdrCJ_1dKvUUc%2Bh%3DfAeV2g3DLz_avPifuoVqPBj%3DdHvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.