1
votes

I want to create one Jenkins job that is connected/listening to multiple Github repository, with a web-hook to trigger the job by opening a pull request in one of the repos using the "pull request builder" plugins.

I saw an option in Jenkins to select Github Organization type job, but it requires a jenkinsfile in each repo which defeats the purpose.

someone suggested that i create a job for each repo and then to trigger a generic job with the repo name as parameters, but if i have 20 repositories i don't want to make 20 jobs.

Does anyone know of a way to do this?

1
That's probably not what you wanted to hear, but 20 jobs isn't so bad, you could do them in 10 minutes by copying one from another - as a bonus you have a. separate history for each trigger job. Other option could be some middleware waiting for web-hook events and triggering the job. - Tupteq
@Tupteq thanks for your input, I created a script to duplicate the jobs but not happy with managing 20 jobs(even due all of the jobs are working with the same jenkinsfile) I was looking at Github-action which will trigger the job from the repo on pull req, but its still not good solution bcs you need to create the action in each repo and mange it, and they do not support stable IP addresses yet. - boaz barkan

1 Answers

1
votes

You can achieve your objective by creating a single Pipeline-type project in Jenkins and by parsing the payload of the GitHub webhook to obtain the parameters that you need to figure out which of your 20+ repos you need to build on each case.

I use the Generic Webhook Trigger plugin to achieve a similar goal. This plugins allows you to parse all the fields of the json included with the webhook. There you can find repo/branch/PR information needed to customize your job run, and feed this parameters to your checkout stage, for example.