Is there a command to know the targeted branch name of a PR when building this PR?
Context:
I am building some code with a "Multibranch Pipeline" jenkins job.
When I create a Github Pull request, this job is triggered and I would like to know, in this job execution, what is the targeted branch name of this PR.
I have tried different commands in my Jenkinsfile but none are giving me the expected result.
If I try this: git rev-parse --abbrev-ref HEAD
it gives me: HEAD
If a execute: git branch
I get: * (HEAD detached at 464f73c0)
What I want to get is, for instance, master
if the PR is targeting master as destination branch.
Any idea ?
Thanks for your help
Thanks to @Vishwanath's idea I was able to find the answer:
In jenkins "Multibranch Pipeline" jobs, when building a PR, the targeted branch is available as an environment variable: CHANGE_TARGET