问题
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?
回答1:
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
.
回答2:
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.
回答3:
Put your jenkins server URL in browser and Put /api/xml infront of your URL.
Example:
https://xyzjenkins.cloud/view/all/api/xml
Or
to get result in json just put json instead of xml in above mentioned URL
https://xyzjenkins.cloud/view/all/api/json
来源:https://stackoverflow.com/questions/37571445/how-to-check-disabled-jobs-with-jenkins-server