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 ?

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

If you want to see all environment variables. Try sh "env" in pipeline
0

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

2 Comments

But if i want to use that branch name somewhere then? shouldn't it be provided in some other parameter ?
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.