Skip to content

Instantly share code, notes, and snippets.

@justlaputa
Last active September 26, 2023 17:43
Show Gist options
  • Save justlaputa/5634984 to your computer and use it in GitHub Desktop.
Save justlaputa/5634984 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

@paramanandd
Copy link

can we find out:

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

@RichardRanft
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....

@rakeshbachu
Copy link

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

@VibhuAgarwal
Copy link

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

@vinay-prasad
Copy link

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?

@s0nghuiming
Copy link

s0nghuiming commented Dec 25, 2018

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

@NeetuGokhe15
Copy link

is there any way to get the all workspaces thr api

@trunaldeshmukh
Copy link

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

@BhavanaBGowda
Copy link

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

@monkpit
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:

https://stackoverflow.com/questions/26236206/jenkins-remote-api-is-it-possible-to-retrieve-the-complete-job-tree-using-the

@Jatin887
Copy link

i am getting a 504 error what can be the issue?

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