Skip to content

Instantly share code, notes, and snippets.

@laxman954
Forked from justlaputa/jenkins-api.md
Last active March 14, 2019 11:50
Show Gist options
  • Save laxman954/3739f6ae85dc3d0068435b0ad62dd60e to your computer and use it in GitHub Desktop.
Save laxman954/3739f6ae85dc3d0068435b0ad62dd60e to your computer and use it in GitHub Desktop.
Jenkins Json API

jobs

jenkins_url + /api/json?tree=jobs[name,color]

builds

jenkins_url + /job/${job_name}/api/json?tree=builds[number,status,timestamp,id,result]

last build

  • all build info:

jenkins_url + /job/${job_name}/lastBuild/api/json

  • build progress:

jenkins_url + /job/${job_name}/lastBuild/api/json?tree=result,timestamp,estimatedDuration

timestamp = start time

estimatedDuration = duration

To Build the Specific Job

jenkins_url + /job/${job_name}/build

Sample

curl -X POST JENKINS_URL/job/JOB_NAME/build \ --user USER:TOKEN \ --data-urlencode json='{"parameter": [{"name":"id", "value":"123"}, {"name":"verbosity", "value":"high"}]}'

Reference - https://wiki.jenkins.io/display/JENKINS/Remote+access+API

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