How to check disabled jobs with Jenkins server?

假如想象 提交于 2019-12-13 14:17:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!