Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check if the hudson is busy 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 following 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?

like image 617
akshay Avatar asked Jul 11 '11 12:07

akshay


4 Answers

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].

like image 87
highlycaffeinated Avatar answered Oct 28 '22 21:10

highlycaffeinated


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?

like image 30
Reverend Gonzo Avatar answered Oct 28 '22 22:10

Reverend Gonzo


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

<overallLoadStatistics>
  <busyExecutors></busyExecutors>
  <queueLength></queueLength>
  <totalExecutors></totalExecutors>
  <totalQueueLength></totalQueueLength>
</overallLoadStatistics>
like image 2
Thor Avatar answered Oct 28 '22 21:10

Thor


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.

like image 1
Anders Lindahl Avatar answered Oct 28 '22 22:10

Anders Lindahl