how to know which git branch triggered the jenkins job

我是研究僧i 提交于 2020-01-06 08:44:14

问题


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.

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.

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.


回答1:


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

ie:

commit = checkout scm
println commit.GIT_URL

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



来源:https://stackoverflow.com/questions/49883240/how-to-know-which-git-branch-triggered-the-jenkins-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!