Skip to content

Instantly share code, notes, and snippets.

@stuart-warren
Last active September 4, 2025 08:12
Show Gist options
  • Select an option

  • Save stuart-warren/7786892 to your computer and use it in GitHub Desktop.

Select an option

Save stuart-warren/7786892 to your computer and use it in GitHub Desktop.

Revisions

  1. stuart-warren revised this gist Dec 4, 2013. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions CreateJob.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,14 @@
    # check if job exists
    curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken

    # with folder plugin
    curl -s -XPOST 'http://jenkins/job/FOLDERHERE/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --
    user user.name:YourAPIToken
    curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken

    # without folder plugin
    curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken

    # 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 user.name:YourAPIToken -H "Content-Type:application/x-www-form-urlencoded"


    # see http://jenkins/api/
  2. stuart-warren revised this gist Dec 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CreateJob.sh
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,6 @@ curl -s -XPOST 'http://jenkins/job/FOLDERHERE/createItem?name=yourJobName' --dat
    user user.name:YourAPIToken

    # without folder plugin
    curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:0h3gefYourRandomToken03he
    curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken

    # see http://jenkins/api/
  3. stuart-warren revised this gist Dec 4, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CreateJob.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # with folder plugin
    curl -s -XPOST 'http://jenkins/job/FOLDERHERE/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --
    user user.name:0h3gefYourRandomToken03he
    user user.name:YourAPIToken

    # without folder plugin
    curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:0h3gefYourRandomToken03he
  4. stuart-warren revised this gist Dec 4, 2013. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion CreateJob.sh
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,8 @@
    # with folder plugin
    curl -s -XPOST 'http://jenkins/job/FOLDERHERE/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --
    user user.name:0h3gefYourRandomToken03he

    curl -s -XPOST 'http://jenkins/jenkins/job/FOLDERHERE/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:0h3gefYourRandomToken03he
    # without folder plugin
    curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:0h3gefYourRandomToken03he

    # see http://jenkins/api/
  5. stuart-warren created this gist Dec 4, 2013.
    2 changes: 2 additions & 0 deletions CreateJob.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@

    curl -s -XPOST 'http://jenkins/jenkins/job/FOLDERHERE/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:0h3gefYourRandomToken03he