K Split X
K Split X

Reputation: 4717

List all folders under Jenkins with their path

Suppose a have a folder named TOPLEVEL, which contains many jobs inside. I want to be able list all the folders that TOPLEVEL contains.

I have tried accessing the following json tree url, but it does not seem to work.

http://jenkins/job/TOPLEVEL//api/json?tree=jobs[name,_class=%22hudson.model.Folder%22]&wrapper=root

It is still giving me stuff like:

{
"_class": "hudson.model.FreeStyleProject",
"name": "testProject1"
}

Nevertheless, it does give me folders, but it also gives me other types of jobs, which I do not want?

{
"_class": "com.cloudbees.hudson.plugins.folder.Folder",
"name": "Github"
}

when I do not require this. Am I doing my API call wrong?

Upvotes: 2

Views: 4322

Answers (1)

I found this https://gist.github.com/justlaputa/5634984

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

Upvotes: 2

Related Questions