how to create a job in a folder?

2,064 views
Skip to first unread message

James Levinson

unread,
Mar 23, 2013, 3:11:29 AM3/23/13
to job-dsl...@googlegroups.com
Not sure if anyone here is using Jenkins Enterprise, but it has a proprietary Folder plugin to logically nest jobs in folders that propagate the statuses of all jobs within them to an icon. It seems like a handy organization tool and more useful than a view, in some cases. In fact, I think they gave it away free at some point.

Meanwhile, I am gearing up to transition a multitude of jobs to use the job-dsl-plugin because it rocks!  I attempted to see if they could work together - meaning, if I create a seed job in a Folder, will the jobs be created in that Folder too ?

They were not. They were created in the default root: http://jenkins-server/job/*. This is not a huge deal and they can be moved, but I was wondering if anyone might know how to make the jobs namespace aware ? I took a look at the config.xml of a dsl created job that I moved in to the folder and it had no element to denote it's namespace.

Not sure if this forum or the cloudbees forum would be more or less appropriate for this one. Let me know.

Thanks.

Justin Ryan

unread,
Mar 25, 2013, 2:11:31 AM3/25/13
to job-dsl-plugin
I've always thought that "seed" jobs should be able to "contain" the jobs they created. There's a lot of hierarchy in the core of Jenkins, so I always assumed we could come back around to it. Your email forced me to look around, and there isn't really any out-of-box way to do it. Hierarchy is used internally by plugins like the Matrix plugin and evidently the Folder plugin, and they then offer a UI over it, which is a shame that it's not just built-in.

I'd have to really look at what the Folder plugin is creating, it might just be another type of job, in which case it should be straight-forward to create it with the job-dsl-plugin. Slightly complicating things is that it's closed source (right?). I'll try to load up the plugin on an instance and see what's it's creating. It's likely we can do it, but then again the way we create jobs (Jenkins.createProjectFromXML) might prevent us from doing it (things like Folders being namespace aware). 

There's always been this area in Jenkins.getItemByFullName that's confused me, it appears that jobs can have slashes in their name to create a hierarchy of ItemGroups, but I have no idea how to create an ItemGroup, add it, and visual it. Anyone know? This is probably how the Folder plugin is working.

(A hack around this for now is to create a view that is regex based, and just name your jobs appropriately)


--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/job-dsl-plugin/-/H1VnX4MJ0vkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

James Levinson

unread,
Mar 25, 2013, 12:49:44 PM3/25/13
to job-dsl...@googlegroups.com
Thanks, Justin. Sure, that workaround is perfectly acceptable. I futzed around with creating the jobs with a path and couldn't get the slashes to take, trying several different escape patterns, like \/, //, in linux. I'll also dig deeper into the source and find getItemByFullName.

James Levinson

unread,
Aug 19, 2013, 6:06:06 PM8/19/13
to job-dsl...@googlegroups.com
Wanted to see if I could rekindle any interest in this by providing the link to the cloudbees api: http://jenkins-enterprise-javadocs.apps.cloudbees.com/

As stated, I think that being able to create a seed job in a com.cloudbees.hudson.plugins.folder.Folder, then running it and having the jobs stick inside the folder would be super handy.

Daniel Spilker

unread,
Aug 19, 2013, 6:15:02 PM8/19/13
to job-dsl...@googlegroups.com
Hi James,

there is an open pull request which will add this feature in the future: https://github.com/jenkinsci/job-dsl-plugin/pull/78.

Regards,
Daniel


--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.

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



--

    daniel spilker

    ma...@daniel-spilker.com
    +49.179.1093202
    geschwister-scholl-straße 62, 20251 hamburg
    http://daniel-spilker.com

James Levinson

unread,
Aug 19, 2013, 6:26:31 PM8/19/13
to job-dsl...@googlegroups.com
herausragende danke


--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/1nt02dnE-aQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugi...@googlegroups.com.

To post to this group, send email to job-dsl...@googlegroups.com.

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



--

James Levinson


Senior Release Engineer


We’re hiring! See jobs here

Andrew Harmel-Law

unread,
Aug 20, 2013, 8:19:10 AM8/20/13
to job-dsl...@googlegroups.com
Looking at it (pull request) now...

Andrew

Andrew Harmel-Law

unread,
Aug 20, 2013, 8:20:45 AM8/20/13
to job-dsl...@googlegroups.com
Merged.

James Levinson

unread,
Aug 20, 2013, 2:41:08 PM8/20/13
to job-dsl...@googlegroups.com
Hi ndeloof,

I know this https://github.com/jenkinsci/job-dsl-plugin/pull/78 just got merged and you probably haven't thought of documentation yet, but I was wondering if you could post a brief example/how-to on this. I've tried it a couple different ways and no success, yet.
  1. Created a Folder as "Folder1" and executed a seed job within the folder with a "/" in the name, like name="Folder1/job" & without "/" in the name, like name=job and I get "FATAL: BUG! exception in phase 'semantic analysis'" on both
  2. tried a seed job outside "Folder1" with "Folder1/job" and get FATAL: '/' is an unsafe character
    hudson.model.Failure: '/' is an unsafe character
    	at jenkins.model.Jenkins.checkGoodName(Jenkins.java:2833)
Perhaps I am escaping incorrectly? I tried \/ & //.

Thanks so much for working on this,

James (hot for this feature)

Matt Sheehan

unread,
Aug 21, 2013, 1:01:35 AM8/21/13
to job-dsl...@googlegroups.com
Hi James. Just added a PR for this fix: https://github.com/jenkinsci/job-dsl-plugin/pull/89 
After the name check is fixed, you should be able to create a job with "Folder1/job" given your seed job is in the root and Folder1 exists.

Thanks,
Matt

James Levinson

unread,
Sep 11, 2013, 1:25:48 AM9/11/13
to job-dsl...@googlegroups.com
Hi Matt,

Thank You so much ! This works. 

Any indications of when 1.17 will be released ?

James
Reply all
Reply to author
Forward
0 new messages