0

I'm currently checking out multiple branches (assume 4 branches) in a Jenkins job and trying to use the branch names of all branches checked out in a script.

I could achieve this in the case of subversion using Jenkins Environment Variables: SVN_BRANCH_n and SVN_URL_n (where n is the number of a branch).
However, this is not possible with GIT_BRANCH_n [Ex: $GIT_BRANCH_1, $GIT_BRANCH_2 etc.,] variable. Can anyone please help me if there is a plugin/solution to have such variable for multiple Git branches in a Jenkins job? Thanks in advance!

Mateusz Chrzaszcz
  • 1,070
  • 13
  • 29
user3816820
  • 37
  • 1
  • 6

1 Answers1

0

One of the possible solutions is to have a step in your Jenkins job, when in bash you list all local branches (using git plumbing interface) and make environment variables for every single of these branches.

Consider using approach mentioned in this question: How to iterate through all git branches using bash script

Mateusz Chrzaszcz
  • 1,070
  • 13
  • 29