0

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

mohet
  • 151
  • 1
  • 4
  • 12

1 Answers1

1

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}")

user_9090
  • 1,884
  • 11
  • 28