Search code examples
gitjenkinsjenkins-pluginsgitlabjenkins-cli

How to use git branch name of Jenkins JOB A in lower stream job B as a parameter to checkout the git branch?


I am working on one issue and seeking for some solution.

I have a jenkin job A where I am building a artifact against a particular git branch.

To pass the name of that branch I am using "Build with parameter" option and it is working fine.

In that job A I am using the promotion process to trigger another job with some specific parameter like PROMOTED_BUILD_NUMBER,PROMOTE_JOB_NAME and deploy layer which is working fine.

My issue is I can't pass the branch name which I am using in my upstream job as a parameter in Job B to checkout only that branch in JOB B.

I was trying to archive the branch name in JOB A and planning to use in some way in JOB B but I am not able to do so.

Can someone know how we can use the branch name in JOB B to checkout that particular branch?


Solution

  • You can use this plugin (Jenkins plugin)
    https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin

    Which lets you pass parameters between jobs and tasks.

    from the docs:

    the parameters of the current build

    You can pass the parameters of the current build which you have in your current job.