Brian T.
Brian T.

Reputation: 161

Easiest way to bulk copy similar Jenkins jobs

Is there any easier way to bulk copy Jenkins jobs? Basically what I want to do is copy all jobs from a particular view to another view and change a couple of parameters to different values.

For example I have a view call Host_1_Test_Jobs. All jobs in this view have a "host" and "plan_id" parameter. I would like to be able to copy all of these jobs to another view and change the two parameters for all of them in one fell swoop.

I can write a Python script to do this by copying the jobs directories and config files, but I was wondering if there is perhaps an easier or more common way to do this.

Or maybe there is a better way to configure these jobs so that I don't have to have create multiple copies (although I would still like separate views for each host's tests results and need to be able to run the jobs in parallel).

Upvotes: 4

Views: 5848

Answers (4)

christoph
christoph

Reputation: 132

use "view-clone" plugin.With view clone you can clone all the projects in a view and replace a string with a string you want.Check this link:https://wiki.jenkins-ci.org/display/JENKINS/View+Cloner+Plugin.For me the cloning part is working but the create view part is failing.Don't know why.

Upvotes: 0

recampbell
recampbell

Reputation: 1247

This is easy to do with the cloudbees folder plugin, which you can get for free via the cloudbees plugin gateway in your update center.

You can create a folder of jobs which are parameterized by environment variables defined at the folder level. You can then make a copy of that folder and change the environment variables for that folder. All of the jobs in that new folder will now use the updated values.

You should also be aware of the template plugin which comes with a paid license for Jenkins Enterprise from CloudBees. The advantage of templates are that you can update them in one place after the fact, which is not the case with other approaches.

Note: I'm an employee of CloudBees.

Upvotes: 2

Gonzalo Matheu
Gonzalo Matheu

Reputation: 10064

You might try: Jenkins-maven-plugin.

It allows you to create jobs using XML and create kind of jobs hierarchy.

Upvotes: 1

gareth_bowles
gareth_bowles

Reputation: 21130

You might want to look using a Matrix build, which will let you run one parameterized job with multiple configurations.

Upvotes: 2

Related Questions