How to pass environment variable to another job Jenkins

Viewed 26

I have a repository in github and two jobs in jenkins: one is triggered by a webhook and thus launches the second one, where the backend is built and delivered. I need to pass the GIT_BRANCH variable from the first job to the second one. How can I do this?

1 Answers

You can add a Job Parameter to the second Job. And then trigger the second Job like below from the first one.

build job: 'SecondJob', parameters: [[$class: 'StringParameterValue', name: 'GIT_BRANCH', value: "$GIT_BRANCH"]]
Related