5

I have a very simple Jenkins build which is needed for several repositories. All these repositories have the same organisation, the same branches, etc. There is no difference except the repository name.

Each single repository should be able to trigger the build for only this specific repository. I imagine something like combining a parameterized build with a WebHook URL containing a query parameter for the repository name maybe.

Any ideas or pointers about that?

Guite
  • 203
  • 1
  • 2
  • 11
  • 1
    I‘d go with the Pipeline job approach using the common code bundled in a global shared library as suggested below. In fact we‘re already doing that. – Joerg S Sep 24 '18 at 11:19
  • Wouldn't that still require manual addition of new jobs for new repositories? – Guite Sep 25 '18 at 07:06
  • I understand you want Jenkins to build projects from new Repositories automatically? – Joerg S Sep 25 '18 at 10:05
  • Yes, repository commits should trigger new builds. Actually what I need is something like a matrix job which uses the source repository as an axis. I could also live with a YAML or JSON file returning an array of repository names and a pipeline job consuming this file. But this would be a simple and quite stupid loop building all repositories each time. The missing part is that each single repository should trigger the corresponding build job (or one common job with a parameter identifying the repository). – Guite Sep 25 '18 at 17:31
  • You could have a seeder job using job DSL to loop through the repositories and create the pipeline jobs using the same shared code. I would really not recommend to build different repositories alternating in the same job as this will totally mix up the build history and make it almost useless. I could also think of having a single pipeline job which always builds all repositories in parallel or sequentially. But still you would need to add a new line per repository. For Bitbucket you can have Jenkins to automatically created new Jobs. Not sure whether this is also possible for GitHub. – Joerg S Sep 28 '18 at 04:05

4 Answers4

1

I know this question is already answered, but there is another simple way of triggering a single Job from multiple GitHub URLs.

You could use Generic Webhook Trigger Plugin to build same Job from different GitHub repositories. You need to assign unique token to the Job and configure the Webhook of multiple GitHub repositories as:

JENKINS_URL/generic-webhook-trigger/invoke?token=TOKEN_NAME

pppai
  • 71
  • 5
0

Somewhere I read about an organization where they put most standard pipelines into comprehensive shared libraries. This article is quite a good read about that.

My own company uses "Seedjobs" to create multiple pipelines with only one job. Read this article for an overview on that idea.

Rob Bajorek
  • 6,382
  • 7
  • 44
  • 51
Michael
  • 2,443
  • 1
  • 21
  • 21
0

We had achieved it through creating Jenkins build templates and configuring each job for each url based on this template

We can have one job configured with parameters, but didn't go for that approach as that is not that easy to know for which git repo it is failing as we need to go through parameters of each build

Templates can be created using the following plugin https://wiki.jenkins.io/display/JENKINS/Template+Project+Plugin

Harshavardhan Konakanchi
  • 4,238
  • 6
  • 36
  • 54
0

After having done a bit more research I think I will try the "GitHub Organization" job type. It scans all repositories for a given GitHub organization or owner and automatically manages corresponding jobs.

Guite
  • 203
  • 1
  • 2
  • 11