Reputation:
We have configured 8 git repos webhook mapped to single pipeline(Jenkins).
This is a scripted pipeline(groovy).
Single pipeline gets triggered based on push/merge event happening on any of the 8 repos.
The pipeline is supposed to checkout develop
branch based on the repository that triggered the pipeline. env.BRANCH_NAME == 'develop'
says that pushed branch is develop
So, on trigger, groovy script would perform git(branch: branchName, credentialsId: credential, url: "${env.GIT_URL_1}")
Can scripted pipeline rely on env.GIT_URL_N
that can provide the information about, which repository(.git
) triggered the scripted pipeline? so that groovy script can read env.GIT_URL_N
and perform checkout on develop
branch..
https://github.com/danger/danger/pull/607
Upvotes: 0
Views: 139
Reputation: 1974
You can just use "${gitlabSourceBranch}" variable if your pipeline is not a multi-branch pipeline. (if you are using GITLAB)
So it would like something:-
git(branch: branchName, credentialsId: credential, url: "${gitlabSourceBranch}")
Upvotes: 0