arrowill12
arrowill12

Reputation: 1804

jenkins job for any gitlab repository

I am wondering if there is a way to have Jenkins listen for pushes to any repository. I want to be able to have jenkins build the repository but I do not want to make a jenkins job for every repository. is there a way that I can specify any repository in my gitlab? I am firing webhooks from each repository, but I am unusre to to use one job to ahndle all repositories?

the reason I would like to do this is because users can create new repos and I dont not want to have to add a job for each one.

thanks!

Upvotes: 0

Views: 2165

Answers (1)

Lovato
Lovato

Reputation: 2310

Yes, you can achieve this.

You first need to install GitLabHookPlugin into Jenkins. https://wiki.jenkins-ci.org/display/JENKINS/Gitlab+Hook+Plugin

Then, you must change your webhooks to: http://your_jenkins.com/gitlab/build_now

Then, read this: https://github.com/elvanja/jenkins-gitlab-hook-plugin#parameterized-projects

You can have a single parametrized job, which will not be attached to a SCM. Inside this job, you will have to do some bash scripting to get the values from payload (https://github.com/elvanja/jenkins-gitlab-hook-plugin#hook-data-related) and perform the same steps Jenkins do, like creating dirs, wipeing files, do gitclones, merges, and so on.

Take a look at the steps Jenkins do on output console...

Marco

Upvotes: 1

Related Questions