如何知道哪个git分支触发了詹金斯工作 [英] how to know which git branch triggered the jenkins job

查看:382
本文介绍了如何知道哪个git分支触发了詹金斯工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个管道Jenkins作业正在按预期方式工作,并配置了选项用于GITScm轮询的GitHub挂钩触发器" ,以便在对git repo进行任何推送时自动构建.

I have a pipeline Jenkins job which is working as expected, configured with the option "GitHub hook trigger for GITScm polling" for auto build on any push to git repo.

我已经将此Jenkins URL链接到多个git repo的说法,例如repo-Arepo-Brepo-B.
Jenkins作业会在将任何代码推送到这些存储库时自动触发.

I have hooked this Jenkins URL for multiple git repo's say repo-A, repo-B, repo-B.
Jenkins job is triggering automatically on any code pushes to these repo's.

但是我想知道哪个回购触发了Jenkins作业,因为它在Jenkins级别配置为多个git回购.任何对此表示赞赏的帮助.

But I would like to know which repo has triggered the Jenkins job as it is configured to multiple git repo's at Jenkins level. Any help on this highly appreciated.

推荐答案

您可以获取 GIT插件变量作为步骤结帐的返回值

You can get GIT Plugin variables as a return value of step checkout

即:

commit = checkout scm
println commit.GIT_URL

PS:您的标题应该是如何知道哪个git 存储库并触发了詹金斯工作".确实,对于获得分支的名称,我只会得到env.BRANCH_NAME

PS: your title should be "how to know which git repository and triggered the jenkins job". Indeed for getting a branch's name I would just get the value of env.BRANCH_NAME

这篇关于如何知道哪个git分支触发了詹金斯工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆