From Jenkins, how do I get a list of the currently running jobs in JSON?

前端 未结 6 1815
执笔经年
执笔经年 2020-12-07 17:41

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         


        
6条回答
  •  情歌与酒
    2020-12-07 18:23

    Bit of a hack but I think you can infer what jobs are currently running by looking at the color key in the job objects when you do a GET at /jenkins/api/json?pretty=true. If the 'ball' icon for a given job in Jenkins is animated, we know it's running.

    Have a look at the array of job objects in the JSON response:

    {
     ...
      "jobs" : [
        {
          "name" : "Test Job 1",
          "url" : "http://localhost:8000/jenkins/job/Test%20Job%201/",
          "color" : "blue"
        },
        {
          "name" : "Test Job 2",
          "url" : "http://localhost:8000/jenkins/job/Test%20Job%202/",
          "color" : "blue_anime"
        }
      ...
    }
    

    In this case "color" : "blue_anime" indicates that the job is currently running, and "color" : "blue" indicates that the job is not running.

    Hope this helps.

提交回复
热议问题