简体   繁体   English

列出使用Jenkins环境变量在jenkins作业中检出的多个git分支

[英]Listing multiple git branches checked out in a jenkins job using Jenkins environment variables

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. 我目前正在Jenkins作业中签出多个分支(假设有4个分支),并尝试使用脚本中签出的所有分支的分支名称。

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). 在使用Jenkins环境变量进行颠覆的情况下,我可以实现此目的:SVN_BRANCH_n和SVN_URL_n(其中n是分支的编号)。
However, this is not possible with GIT_BRANCH_n [Ex: $GIT_BRANCH_1, $GIT_BRANCH_2 etc.,] variable. 但是,使用GIT_BRANCH_n [Ex:$ GIT_BRANCH_1,$ GIT_BRANCH_2等]变量是不可能的。 Can anyone please help me if there is a plugin/solution to have such variable for multiple Git branches in a Jenkins job? 如果在Jenkins工作中有多个Git分支具有这样的变量的插件/解决方案,谁能帮我吗? Thanks in advance! 提前致谢!

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. 一种可能的解决方案是在Jenkins工作中迈出一步,在bash中,您列出所有本地分支(使用git plumbing接口)并为这些分支中的每个分支创建环境变量。

Consider using approach mentioned in this question: How to iterate through all git branches using bash script 考虑使用此问题中提到的方法: 如何使用bash脚本遍历所有git分支

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM