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 ?
Asked
Active
Viewed 2,031 times
2 Answers
3
I was able to get the branch name from env.CHANGE_BRANCH
in case of a pull request.

Pete
- 787
- 9
- 10
-
1If you want to see all environment variables. Try sh "env" in pipeline – Gopinath V S Aug 21 '20 at 13:56
0
You will get the exact branch name after merging the code. It's just to differ

Ginanjar R.
- 21
- 3
-
But if i want to use that branch name somewhere then? shouldn't it be provided in some other parameter ? – deenbandhu Sep 05 '17 at 09:08
-
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. – Ginanjar R. Sep 06 '17 at 01:40