Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user
# create folder
curl -XPOST 'http://jenkins/createItem?name=FolderName&mode=com.cloudbees.hudson.plugins.folder.Folder&from=&json=%7B%22name%22%3A%22FolderName%22%2C%22mode%22%3A%22com.cloudbees.hudson.plugins.folder.Folder%22%2C%22from%22%3A%22%22%2C%22Submit%22%3A%22OK%22%7D&Submit=OK' --user -H "Content-Type:application/x-www-form-urlencoded"
# see http://jenkins/api/
Copy link

AnthonyClink commented Apr 8, 2015

this is a life saver thanks

Copy link

Balasekhar commented Sep 9, 2015


Copy link

PratikshaKP commented Oct 27, 2015

What does mode stand for in the last API?

Copy link

ygaller commented Feb 24, 2016

Another way to check whether job exists:
curl -XGET 'http://jenkins/job/yourJobName/api/json' --user
This returns either 200 or 404 depending on whether the job already exists.

Copy link

harenderbits commented Apr 13, 2016

Can i send string parameters and there value ....while creating job with curl. I need to create a job which is parameterized through the api.

Copy link

pesetskyps commented Jul 4, 2016

thank you, helped a lot

Copy link

ilanni2460 commented Sep 9, 2016

very good tks

Copy link

fboukezzoula commented Jan 27, 2017

Thanks. I will try it on Monday at desk :o)

Copy link

razbomi commented Jul 6, 2017


Copy link

jingjingpiggy commented Jul 21, 2017

Hi, do you have jenkins :)

Copy link

marco2704 commented Mar 9, 2018

Hi @stuart-warren, for the create folder request, from parameter is needed?
According to
from parameter is only used when the mode parameter equals "copy".


Copy link

vamsikrishnakoni commented Mar 29, 2018

Any API we can add the user to the Jenkins with read and build access for a jenkins job ?


Copy link

marco2704 commented Apr 21, 2018

Hi @vamsikrishnakoni
You can take a look at There are examples with cURL for managing roles.

I'm not sure whether you can add the user and assign a role in once. Hope it helps you 😄

Copy link

Eric-Fontana-Bose commented Jun 10, 2019

How do you "Move" a job which is not currently in a folder to a newly created folder? Using whatever API possible?

Copy link

arellano-gustavo commented May 16, 2020

Is it possible to send instead xml content, only json ? How?

Copy link

Asgoret commented Jul 22, 2020

Thanks! It's really to save my time!

Copy link

abdennour commented Feb 26, 2021

thanks man!

Copy link

sw-dev-code commented Mar 21, 2021

Thank you for the commands. I'm just wondering if there is an instruction on how to do the same thing with the config file in JSON format if that is possible?

Also, does anybody know about the document or tutorial on how to create config.xml for a new job?

Thank you in advance.

Copy link

sauravrout commented Nov 12, 2021

Thanks for the command, I am wondering if there is an option to overwrite an existing job.

Copy link

syedahaider97 commented Jan 27, 2022

Thanks, this worked great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment