מורן זהובה
מורן זהובה

Reputation: 35

How to check disabled jobs with Jenkins server?

I am using Jenkins to run tests on my servers.

So I created a job for each server and I run the test on the job, and I would like to know with simple bash script if my specific job is disabled/enabled?

I can ssh to Jenkins server and I want to run that script from there how I can do that?

Upvotes: 3

Views: 7667

Answers (4)

vitalii
vitalii

Reputation: 1

Wanted to add to the existing answer. To get more precise result you can add xpath filter

http://<Your Jenkins>/job/<job name>/api/xml?xpath=//disabled

or

http://<Your Jenkins>/job/<job name>/api/xml?xpath=//buildable

In response you will get only one line:

<disabled>true</disabled>

Filtering also works with json api output:

http://<Your Jenkins>/job/<job name>/api/json?tree=disabled&pretty=true

Output:

{
  "_class" : "hudson.model.FreeStyleProject",
  "disabled" : true
}

Upvotes: 0

Dashrath Mundkar
Dashrath Mundkar

Reputation: 9212

Put your jenkins server URL in browser and Put /api/xml infront of your URL.

Example:

https://xyz.jenkins.com/view/all/api/xml

Or

to get result in json just put json instead of xml in above mentioned URL

https://xyz.jenkins.com/view/all/api/json

Upvotes: 1

Mallappa
Mallappa

Reputation: 49

Check the project status from this string

curl http://$JENKINS_URL/job/$JOB_NAME/api/json | python -mjson.tool

It will dump the job data in json format. then grep for string "buildable":

this will give you whether project is wither either enabled or disabled.

"buildable": true, --> Project enabled
"buildable": false,  --> Project Disabled

Then do whatever you want.

Upvotes: 4

Gerold Broser
Gerold Broser

Reputation: 14772

See http://<Your Jenkins>/api and http://<Your Jenkins>/api/xml:

<hudson>
  ...
  <job>
    <name>...your job name...</name>
    ...
    <color>disabled</color>
  </job>
  ...

For a job's description see http://<Your Jenkins>/job/<Your job's name>/api and http://<Your Jenkins>/job/<Your job's name>/api/xml.

Upvotes: 3

Related Questions