akshay
akshay

Reputation: 5285

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?

Upvotes: 6

Views: 979

Answers (4)

Anders Lindahl
Anders Lindahl

Reputation: 42870

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.

Upvotes: 1

Thor
Thor

Reputation: 6656

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

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

Upvotes: 2

highlycaffeinated
highlycaffeinated

Reputation: 19867

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

Upvotes: 7

Reverend Gonzo
Reverend Gonzo

Reputation: 40811

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?

Upvotes: 1

Related Questions