Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Jenkins Json API


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


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

Copy link

ranbharerp15 commented May 10, 2016

Can anyone tell me, how to obtain all the job names and their URLs under a project via jenkins JSON API?

Copy link

nejatcanunlu commented Jul 30, 2016

You need to make a get request to http://{jenkins-url}/api/json

Keep in mind that you'll need to authenticate this request with valid credentials.

Copy link

irodkin commented Sep 9, 2016

@ranbharerp15, if by project you mean views in jenkins then like this:
where "pretty=true&" part is optional.

Copy link

jk1510karti commented Oct 3, 2016

Hi Team,

I am creating new Service end point with jenkins from Visual Studio online. I have installed jenkins on my windows server. I can able to access the jenkins URL from remote machine(which is in same network). But when I try to make connection from visual studio online i'm getting timeout issues.

You can find the error screenshot here.

Copy link

anudeeplalam commented Oct 3, 2016

Hi When I try to access jenkins_url + /job/${job_name}/lastBuild/api/json , I am getting Server returned HTTP response code: 403 for URL error.. Can someone help me.

Copy link

vitalyisaev2 commented Oct 12, 2016

Thanks for a nice snippet. Could anyone please explain, is it possible to lool for a job with particular parameters on the server side. I know it's possible to request all the available builds. For instance:

$ curl  -g http://admin:d8e8c63306e04c8b8aafade1275697b3@localhost:8080/job/sss/api/json?tree=builds[id,queueId,url] 2>/dev/null | python -m json.tool
    "_class": "hudson.model.FreeStyleProject",
    "builds": [
            "_class": "hudson.model.FreeStyleBuild",
            "id": "2",
            "queueId": 21,
            "url": "http://localhost:8080/job/sss/2/"
            "_class": "hudson.model.FreeStyleBuild",
            "id": "1",
            "queueId": 20,
            "url": "http://localhost:8080/job/sss/1/"

But is it possible to get the job with particular parameter? Say, where queueId == 20.

Copy link

shafi-codez commented Oct 18, 2016

you can ingest this data further & parse using jq tool

Copy link

paramanandd commented Jan 3, 2017

can we find out:

Number of successful builds in a time span e.g. a month

Copy link

RichardRanft commented Dec 12, 2017

The "property" item of the job JSON is some sort of list of anonymous objects:
"property":[ { "parameterDefinitions":[ { "defaultParameterValue":{ "name":"BUILD_CONFIG", "value":"BJX" }, "description":"", "name":"BUILD_CONFIG", "type":"StringParameterDefinition" }, .... <snip> .... ] }, {} ],
So it's difficult to make a tool to get this in C# since you can't make a class with an anonymous list - the object has to have a name. I'm sort of stuck on getting my parameter definitions here....

Copy link

rakeshbachu commented Feb 5, 2018

any idea on how to filter builds between 2 time stamps
like 2-4 pm today?

Copy link

VibhuAgarwal commented Jun 12, 2018

Can anyone tell me how to push all log files or jobs from jenkins to logstash?

Copy link

vinay-prasad commented Sep 21, 2018

This is very helpful. Could you please tell me how to get access to any file in the workspace e.g. I want to see test coverage xml inside target. Is there an API for that?

Copy link

s0nghuiming commented Dec 25, 2018

Ji, masters. What's your comments about getting an ID list of spec job using API?

Copy link

NeetuGokhe15 commented Jan 15, 2019

is there any way to get the all workspaces thr api

Copy link

trunaldeshmukh commented Mar 25, 2019

Hi ,
Can anyone suggest me the way to retrieve the no of items inside pending queue for a given job

Copy link

BhavanaBGowda commented Dec 23, 2019

Is there a way to get all the jenkins build jobs that are in the build queue from a specific view?

Copy link

monkpit commented Jan 29, 2020

How do I get all jobs including those within folders?

EDIT: Found this which is an answer, but not a very satisfying one:

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