问题
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