3

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 ?

deenbandhu
  • 599
  • 5
  • 18

2 Answers2

3

I was able to get the branch name from env.CHANGE_BRANCH in case of a pull request.

Pete
  • 787
  • 9
  • 10
0

You will get the exact branch name after merging the code. It's just to differ

  • 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