I am using Jenkins multibranch pipeline pull request feature when i print env.BRANCH_NAME it prints PR-pullrequestnumber. instead of that i want to get branch name how could i get it ?
2 Answers
I was able to get the branch name from env.CHANGE_BRANCH in case of a pull request.
1 Comment
Gopinath V S
If you want to see all environment variables. Try sh "env" in pipeline
You will get the exact branch name after merging the code. It's just to differ
2 Comments
deenbandhu
But if i want to use that branch name somewhere then? shouldn't it be provided in some other parameter ?
Ginanjar R.
when you view environment variable with command
env there's variable $CHANGE_TARGET. That contain's you branch name. I use that whenever doing deployment without merging the repo.