Moving a job to a Folder

2,354 views
Skip to first unread message

Daniel Laird

unread,
Aug 6, 2015, 4:45:47 PM8/6/15
to Jenkins Users
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

Gergely Brautigam

unread,
Aug 10, 2015, 9:02:32 AM8/10/15
to Jenkins Users
Hi Dan.

It's simple. On the Job, on the Left side, you see this option =>

 Move

Click on that, and select the directory in which you would like to move the job. This will also update references to the job, and copy the whole workspace and configuration history, so nothing will get lost.

Gergely.

VFloyd

unread,
Aug 14, 2015, 1:48:03 PM8/14/15
to Jenkins Users
Any ideas on how to move more than one job at a time into a folder?

Stephen Connolly

unread,
Aug 14, 2015, 6:00:07 PM8/14/15
to jenkins...@googlegroups.com
You could use a groovy script. Other than that you are SOoL

For CloudBees Jenkins Platform I have just implemented move/copy functionality for use within/between masters, and that functionality comes with Jenkins CLI support so you could use shell scripting with that *if you are a CloudBees customer*. (Still going through QA and documentation before we can release it though... Should be out next week with any luck)

I believe we have a Jenkins CLI command already in the folders plugin... If we don't then that's something that's in our OSS backlog (ie I cannot remember if we did it already or not!)
--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e4cd1d42-0fba-4faf-a023-caab8b466a52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Sent from my phone

Vanetta Floyd

unread,
Aug 14, 2015, 7:49:12 PM8/14/15
to jenkins...@googlegroups.com

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?

--
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 jenkinsci-use...@googlegroups.com.

Stephen Connolly

unread,
Aug 15, 2015, 2:19:24 AM8/15/15
to jenkins...@googlegroups.com
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
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAL40ccPVuPWnNeaRostT0uggh6PaOmwE3KUzTPN2mbdqvtX%2BvQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Vanetta Floyd

unread,
Aug 15, 2015, 7:36:27 AM8/15/15
to jenkins...@googlegroups.com

Please accept my apologies for misunderstanding the answer you provided, as well as the purpose of this board.

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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CA%2BnPnMwBeqFvZAspj%2BcFRekgQvKrbSg4JZm9Fn9wX_63ei2Ndw%40mail.gmail.com.

Stephen Connolly

unread,
Aug 15, 2015, 9:58:08 AM8/15/15
to jenkins...@googlegroups.com


On Saturday, August 15, 2015, Vanetta Floyd <vanett...@gmail.com> wrote:

Please accept my apologies for misunderstanding the answer you provided,


No worries, it may have been less than entirely clear due to being composed on a phone
 

 as well as the purpose of this board.


To be clear, this mailing list is not here to advertise CloudBees products... We have a marketing department who are paid to advertise our products.

My intent in mentioning was to point out that I am currently intimately aware of the move functionality available in Jenkins OSS having just completed a new feature integrating with it (but sadly that feature is not one I can share with OSS)... Though we do have stories to push what we can push back to OSS
 
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAL40ccPMzS4FkoAr28Jt54j1pTCDGDMykJ4nUiTiK-6zfZxR3w%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Daniel Serodio

unread,
Aug 20, 2015, 3:12:40 PM8/20/15
to Jenkins Users
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 <vanett...@gmail.com> 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" <vanett...@gmail.com> 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 jenkinsci-users+unsubscribe@googlegroups.com.

--
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 jenkinsci-users+unsubscribe@googlegroups.com.

Khai Do

unread,
Aug 21, 2015, 2:55:27 PM8/21/15
to Jenkins Users
We are working to add cloudbees folder support to the python-jenkins package (https://python-jenkins.readthedocs.org/en/latest/)  that will allow you to automate management (create/update/move/etc..) of folders.   The change is under review right now (https://review.openstack.org/#/c/180185/) and is very close to being approved.  Hopefully it will get in sometime next week.  python-jenkins is open sourced, so use as you wish, would just love more contributions to make it better :)

kumar naresh

unread,
Jun 6, 2016, 9:17:13 AM6/6/16
to Jenkins Users
Hi Daniel,

could you please let me know exactly how to create a jenkins folder job using groovy script.

Regards,
Naresh.

Sverre Moe

unread,
Jun 6, 2016, 9:32:47 AM6/6/16
to Jenkins Users
import com.cloudbees.hudson.plugins.folder.Folder

def jenkinsInstance = jenkins.model.Jenkins.getInstance()
def newProject = jenkinsInstance.createProject(Folder.class, "my-folder-project")
Message has been deleted

kumar naresh

unread,
Jun 9, 2016, 2:05:39 AM6/9/16
to Jenkins Users

Hi Sverre Moe,


thanks that works really good.

I'm actually trying to add build step to execute shell existing jenkins job using groovy script, let me know if there any steps to do so.

Regareds,
kumar.

Sverre Moe

unread,
Jun 9, 2016, 2:14:46 AM6/9/16
to Jenkins Users
Try the Groovy Postbuild Plugin
You could also use the build step "Execute system Groovy script"
Message has been deleted

Muthu Kumaran

unread,
Nov 23, 2017, 10:15:12 AM11/23/17
to Jenkins Users
Hi,

I am trying to add users to a folder group in Jenkins. Can anyone let me know how to accomplish this via groovy script.

1. List the folder
2. List the groups in the folder
3. Add user to the folder group.

Your help is much appreciated.

Thanks in Advance. 

Muthu

Victor Martinez

unread,
Nov 23, 2017, 2:04:57 PM11/23/17
to Jenkins Users
I guess, this is something outside of what this particular topic was about. Maybe it's worth raising this question in another new thread?

Muthu Kumaran

unread,
Nov 24, 2017, 6:06:56 AM11/24/17
to Jenkins Users
Sure Victor,

you can put this in a separate thread. I was expecting a solution for this issue. Even any relevant articles would be good.


On Friday, November 24, 2017 at 12:34:57 AM UTC+5:30, Victor Martinez wrote:
Reply all
Reply to author
Forward
0 new messages