I have 10 jenkins job in folder foo
. I have created a new sub folder baar
in folder foo
. How to move the 10 jobs from folder foo
to the subfolder baar
?
4 Answers
First, you need to install cloudbees folder plugin then you will see Move option in jobs
click on it,then option(drop down) will come where you want to move
select and move

- 667
- 5
- 11
-
3One thing worth mentioning is that the "Move" option is only displayed when at least one folder exist on the server. – ZeWaren Mar 08 '19 at 17:13
-
1Where do you mean by server? I can't find the move option too. – Badhon Jain Oct 29 '19 at 09:33
-
Now I know what you mean, we have to create it from Jenkin's New Item option. – Badhon Jain Oct 29 '19 at 10:05
-
Is it possible to select multiple jobs and move them all to the same folder? – Mike Rosoft May 11 '20 at 10:09
As @Pratik Anand mentionned you will first need to install the CloudBees Folders Plugin.
However, if you want to move many projects at the same time, it is much faster to do it with the script console. This groovy script does the trick :
def FOLDER_NAME = '<An existing destination folder>'
def JOB_REGEX = '<A regex to find your jobs>'
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
jenkins = Jenkins.instance
def folder = jenkins.getItemByFullName(FOLDER_NAME)
if (folder == null) {
println "ERROR: Folder '$FOLDER_NAME' not found"
return
}
// Find jobs in main folder
def found = jenkins.items.grep { it.name =~ "${JOB_REGEX}" }
println "Searching main folder : $found"
// Find jobs in other subfolders
jenkins.items.grep { it instanceof com.cloudbees.hudson.plugins.folder.Folder }.each { subfolder ->
if(!subfolder.getName().equals(FOLDER_NAME))
{
println "Searching folder '$subfolder.name'"
subfolder.getItems().grep { it.name =~ "${JOB_REGEX}" }.each { job ->
println "Found $job.name"
found.add(job);
}
}
}
// Move them
found.each { job ->
println "Moving '$job.name' to '$folder.name'"
Items.move(job, folder)
}
I used Daniel Serodio's reply in this thread and modified it to search subfolders also. Note that this is not fully recursive.

- 1,031
- 1
- 13
- 29
-
-
In the last line "Items.move(...)" what is Items? I don't see it defined anywhere? In my case I just want to move 1 job to a folder. – Chris F Feb 15 '19 at 01:20
-
@Chris F `hudson.model.Items` You can see the details in the Jenkins javadoc: https://javadoc.jenkins.io/ However, if you only want to move one job, using the CloudBees Folders plugin directly is much simpler. – JM Lord Feb 21 '19 at 16:31
If your jobs are written in DSL, you can create a folder thus:
folder("foo") {
displayName('foo')
description('A folder with all my foo')
}
folder("baar") {
displayName('baar')
description('A folder with all my baar')
}
Then, in your dsl for your jobs, you simply have to reference that folder in the job creation:
job('baar/myJob') {
description('A job which now lives in the baar folder.')
...
}
Once the DSL plugin processes your job you will see it in that folder. However, the folder has to already exist, so I generally name my folder DSL something like all_folders.groovy
so it gets processed first. If you don't specify a folder in the job
declaration it will be in the main Jenkins view.

- 61
- 4
-
When I try to do this, I end up with two pipelines, the old one and the new one – xpmatteo Dec 02 '21 at 10:52
Did you try to use the plugin folder ?
https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Folders+Plugin
You can then move the jobs with the function: "move"

- 997
- 12
- 28