Jenkins api create job in a folder

1,881 views
Skip to first unread message

Glenn V

unread,
Feb 28, 2014, 11:18:23 AM2/28/14
to jenkins...@googlegroups.com
Hi,

I'm using the scriptler plugin to write a groovy script using the Jenkins api, that will clone a set of jobs. With jenkins.model.Jenkins.createProjectFromXML(String name, InputStream xml) I can create new jobs just fine, but that only seems to create top level items.

Because I use the "Cloudbees Folder" plugin to structure my jobs I would like to create the new jobs inside an existing folder. Is there a way to do this?

Any help appreciated,

Glenn


Daniel Beck

unread,
Feb 28, 2014, 3:23:58 PM2/28/14
to jenkins...@googlegroups.com
Folder#createProjectFromXML(String,InputStream). It's from the ModifiableTopLevelItemGroup interface that both Jenkins and Folder implement.
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

Michel Leclerc

unread,
Aug 20, 2015, 12:17:37 PM8/20/15
to Jenkins Users, m...@beckweb.net
Daniel,

i'm experiencing the same exact problem with CreateProjectFromXML. Your answer seems to solution this problem. But i can't quite understand the meaning of your answer. Could you be more explicite? 

Thanks

Michel Leclerc

Daniel Serodio

unread,
Aug 20, 2015, 3:22:19 PM8/20/15
to Jenkins Users, m...@beckweb.net
I think Daniel Beck means that instead of calling Jenkins.createProjectFromXML(...), you find the folder you want and then call folder.createProjectFromXML(...)

Regards,
Daniel Serodio

Khai Do

unread,
Dec 11, 2015, 5:46:13 PM12/11/15
to Jenkins Users, m...@beckweb.net
An option you might like to explore is to use python-jenkins.  We use it to automate folder and job creation.  Doc is here:  https://python-jenkins.readthedocs.org/en/latest/examples.html#example-7-working-with-jenkins-cloudbees-folders
Reply all
Reply to author
Forward
0 new messages