Jenkins
has the Gerrit
Plugin in place so that when we do check-ins to Gerrit
, Jenkins
performs a build and if it succeeds, then the modification in Gerrit
is verified. If the build fails then it is not. My understanding is that this is accomplished through jobs set up in Jenkins
. We have now created a new branch (git
) and I guess I need to clone the existing jobs pointing to the other branch so that this same workflow occurs and builds are performed on every commit. Can somebody explain how I would clone these jobs? I don't seem to see a way to do it through the UI nor can I even see a way to list the jobs out through the UI.
12 Answers
To copy an existing job, go to http://your-jenkins/newJob
and use the "Copy existing job" option. Enter the name of the existing job - Jenkins will verify whether it exists.
The default tab on the front page of Jenkins should list all existing jobs, but maybe your predecessor deleted the tab. You can create a new tab listing all jobs from http://your-jenkins/newView.
Jenkins 2.9
Jenkins > New Item
Enter an item name - E.g. "MY_CLONE"
Specify the source (Copy from) job > OK
When you start typing the name, the existing values will be found. Notice that this is case sensitive.
Click on Save if you want to keep the default values.
Now both jobs are available in the same location:
In my case, I had to copy over a job from one jenkins instance to another.
So first I looked under the directory structure of the old Jenkins (the job/directory name; also noted the config.xml) and then under the directory structure of the new jenkins where I then created a directory with same name/job and copied over the config.xml under this newly created dir.
Then under, "Manage Jenkins", I hit "Reload Configuration from Disk". Thats it.
All above answers are good. But if you have created "folders" for your jobs, things are slightly different.
Click on the folder under which you want to create a new job. Then click "New Item" on the left menu. Now your "new job" URL will look like this (assuming you are creating the new job under "my-folder"):
http://my-jenkins:8080/job/my-folder/newJob
Under Enter an item name
, enter your desired new job name.
Then use the Copy from
text box at the bottom. Enter job path of he source job.
E.g. If your source job is under folder src-folder
and name of the job is src-job
, you will have to enter src-folder/src-job
in "Copy from" box.
Hope it helps.
You can also use the Copy project link plugin.
This will add a link on the left side panel of your project:
Following screen will ask for the new Job name:
I was not able to copy Jenkins job from subfolder. copy from
option did not show the suggestion which i was looking for.Without using suggestion copying the job name didn't work.
So if you want to create a job from outer folder, you need to first create the job in subfolder and then move it in different folder where you need to place it.
All the answers here are super helpful but miss one very weird bug about Jenkins. After you have edited the new job configurations, sometimes if your zoom level is too high, you may not see the save
or apply
button option. The button is present on the page and hidden by your zoom level, you have to zoom out until you see the button at the bottom left of your page.
Strange, I know!