We use this Groovy script to move jobs to folders, maybe you can use it as
a starting point for your needs:
###############################
def FOLDER_NAME = 'Destination folder'
def JOB_REGEX = 'Regex to match 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
}
jenkins.items.grep { it.name =~ "${JOB_REGEX}" }.each { job ->
println "Moving '$job.name' to '$folder.name'"
Items.move(job, folder)
}
###############################
Regards,
Daniel Serodio
On Saturday, August 15, 2015 at 3:19:24 AM UTC-3, Stephen Connolly wrote:
>
> What I said:
>
> 1. You can use a groovy script right now. Will do exactly what you need.
> Some research required.
>
> 2. Oh look some synchronicity, I happen to have just been working on some
> stuff that would do this for a bigger set of problems... Sadly the stuff I
> was working on is for our paid product
>
> 3. The OSS should have a CLI command too... I think it does, but if I am
> wrong, adding a CLI command for the OSS plugin is something on our backlog,
> so we will get to it.
>
> I mentioned #2 not as a plug but more as a "oh, if you did happen to also
> be one of our customers"... Apologies if it read differently.
>
> -Stephen
>
> On Saturday, August 15, 2015, Vanetta Floyd <[email protected]
> <javascript:>> wrote:
>
>> Thanks...not interested in commercials for that product. I'm interested
>> in what the open source community has to say.
>>
>> Will all people asking questions going forward be spammed with plugs for
>> that product?
>> On Aug 14, 2015 10:48 AM, "VFloyd" <[email protected]> wrote:
>>
>>> Any ideas on how to move more than one job at a time into a folder?
>>>
>>>
>>>
>>> On Thursday, August 6, 2015 at 1:45:47 PM UTC-7, Daniel Laird wrote:
>>>>
>>>> All,
>>>>
>>>> I amusing the cloudbees plugin that creates folders.
>>>> I am now trying to move some jobs that are currently in a 'view' into a
>>>> folder.
>>>> I can easily query and list all the jobs in a view in groovy but I am
>>>> struggling to move the job into a folder.
>>>> I have tried various methods - if anyone has some example of doing this
>>>> it would be greatly appreciated.
>>>>
>>>> Dan
>>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Jenkins Users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/jenkinsci-users/doYddgacqTQ/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/e4cd1d42-0fba-4faf-a023-caab8b466a52%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/jenkinsci-users/e4cd1d42-0fba-4faf-a023-caab8b466a52%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-users/CAL40ccPVuPWnNeaRostT0uggh6PaOmwE3KUzTPN2mbdqvtX%2BvQ%40mail.gmail.com
>>
>> <https://groups.google.com/d/msgid/jenkinsci-users/CAL40ccPVuPWnNeaRostT0uggh6PaOmwE3KUzTPN2mbdqvtX%2BvQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Sent from my phone
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/e87f399b-ae21-4939-9d93-f18a52e57f15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.