Jeff W
Jeff W

Reputation: 436

Using createItem remote API with CloudBees folder plugin to create nested jobs or subdirectories

I am attempting to create nested directories and jobs mirroring the structure of my SVN repository using the CloudBees Folder plugin and Jenkins remote API.

For a subdirectory (assume I've copied the config.xml to my CWD):

wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/createItem?name=foo' 

works. When the command completes, I have a newly created "foo" folder in the top level of my dashboard. However when I try:

wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/createItem?name=foo/bar' 

I get a "ERROR 400: Bad Request". I've also tried substituting "name=/foo/bar", "name=%2Ffoo%2Fbar", and "name=foo%2Fbar", all with the same results.

Likewise, I get a similar result when using the createItem/from/mode/name API to copy internal folders:

wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/createItem?name=foo/bar&mode=copy&from=foo'

I find this very unusual since - through the web interface - I can easily move, copy, and create nested directories and jobs.

I am using Jenkins 1.569 with the CloudBees Folders 4.7 plugin.

Upvotes: 1

Views: 2629

Answers (1)

Jesse Glick
Jesse Glick

Reputation: 25451

name may only be a simple name. The endpoint you are looking for is on the folder, not at root level. Thus

wget --no-proxy --auth-no-challenge --http-user=username --ask-password --header="Content-Type: application/xml" --post-file="dconfig.xml" 'http://ci.mycompany.com/jenkins/job/foo/createItem?name=bar'

Upvotes: 6

Related Questions