I can find out just about everything about my Jenkins server via the Remote API, but not the list of currently running jobs.
This,
http://my-jenkins/computer/api/json
or
http://my-jenkins/computer/(master)/api/json
Would seem like the most logical choices, but they say nothing (other than the count of jobs) about which jobs are actually running.
Get a list of jobs. This can be done requesting http://jenkins_url:port/api/json?tree=jobs[name,url] . Response example: { "jobs" : [ { "name" : "JOB_NAME1", "url" : "http://jenkins_url:port/job/JOB_NAME1/" }, { "name" : "JOB_NAME2", "url" : "http://jenkins_url:port/job/JOB_NAME2/" }, ... }
Jenkins can run as many jobs as you have available "executors". You can change the number of executors at will in the configuration.
On your Jenkins server, browse to /env-vars. html . On my localhost test server, the path is this: http://localhost:8080/env-vars.html/. That will give you a list of the environment variables available to your job.
There is often confusion between jobs and builds in Jenkins, especially since jobs are often referred to as 'build jobs'.
See https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project for more information.
If you want the jobs that are currently building (i.e. have one or more running builds), the fastest way is to use the REST API with XPath to filter on colors that end with _anime
, like this:
http://jenkins.example.com/api/xml?tree=jobs[name,url,color]&xpath=/hudson/job[ends-with(color/text(),%22_anime%22)]&wrapper=jobs
will give you something like:
<jobs> <job> <name>PRE_DB</name> <url>http://jenkins.example.com/job/my_first_job/</url> <color>blue_anime</color> </job> <job> <name>SDD_Seller_Dashboard</name> <url>http://jenkins.example.com/job/my_second_job/</url> <color>blue_anime</color> </job> </jobs>
Jenkins uses the color
field to indicate the status of the job, where the _anime
suffix indicates that the job is currently building.
Unfortunately, this won't give you any information on the actual running build. Multiple instances of the job maybe running at the same time, and the running build is not always the last one started.
If you want to list all the running builds, you can also use the REST API to get a fast answer, like this:
http://jenkins.example.com/computer/api/xml?tree=computer[executors[currentExecutable[url]],oneOffExecutors[currentExecutable[url]]]&xpath=//url&wrapper=builds
Will give you something like:
<builds> <url>http://jenkins.example.com/job/my_first_job/1412/</url> <url>http://jenkins.example.com/job/my_first_job/1414/</url> <url>http://jenkins.example.com/job/my_second_job/13126/</url> </builds>
Here you see a list off all the currently running builds. You will need to parse the URL to separate the job name from the build number. Notice how my_first_job
has two builds that are currently running.
I have a view defined using View Job Filters Plugin that filters just currently running jobs, then you can use /api/json
on the view page to see just the jobs that are running. I also have one for aborted, unstable, etc.
UPDATE
Select Edit View → Job Filters → Add Job Filter ▼ → Build Statuses Filter
Build Statuses: ☑ Currently Building
Match Type: Exclude Unmatched - ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With