How to move jenkins work to a subfolder?

I have 10 jenkins job in foo folder. I created a new baar folder in the foo folder. How to move 10 jobs from foo folder to baar subfolder?

+6
source share
3 answers

First, you need to install the plugin for cloud platforms , after which you will see the Move option in tasks

enter image description here

click on it, then the (drop down) option will appear where you want to move enter image description here

select and move

+11
source

As @Pratik Anand noted, you 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 this 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 in this thread and modified it to find subfolders. Please note that this is not completely recursive.

+3
source

Have you tried to use the plugins folder?

https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Folders+Plugin

Then you can move the tasks using the function: "move"

+1
source

All Articles