开发者

how to check if the hudson is busy or not?

开发者 https://www.devze.com 2023-03-19 22:11 出处:网络
How can check if the hudson is busy or not? Meaning i want to check if its currently executing anybuild or not.

How can check if the hudson is busy or not? Meaning i want to check if its currently executing any build or not.

Currently am using followin开发者_JAVA技巧g thing:

    if(lastBuild == lastCompletedBuild){
        // hudson is free
    }
    else{
      //hudson is busy
   }

Is this a correct logic? What if the machine restarts/crashes after last build is updated and lastCompletedbuild is not?

Is there any API exposed which can directly be used?


If you want to see what items are currently in the build queue, you can make an request to http://your.hudson.server/hudson/queue/api/[xml|json].


You can try to query the Load Statistics available at a separate API:

<overallLoadStatistics>
  <busyExecutors></busyExecutors>
  <queueLength></queueLength>
  <totalExecutors></totalExecutors>
  <totalQueueLength></totalQueueLength>
</overallLoadStatistics>


Look at Hudson's API.

Specifically: You can add /api/[xml|json] to any path in Hudson to get machine readable data of that page. For example hudsonserver:8080/api/xml will return the list of job and their current statuses.

However, the real question i where is this code being executed? Above, you have lastBuild and lastCompletedBuild, but where did those variables get set?


Are you interested in whether a specific job is currently building? In that case:

http://[hudson-host-and-path]/job/[job-name]/lastBuild/api/xml

has the tag <building> set to true if a build is currently happening.

0

精彩评论

暂无评论...
验证码 换一张
取 消