How to check if hudson is busy or not?

How to check if hudson is busy or not? I want to check if any assembly is currently in progress or not.

I am currently using the following:

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

Is this the correct logic? What if the machine reboots / fails after the last build is updated and lastCompletedbuild is not?

Is there any API that can be used directly?

+6
source share
4 answers

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

+8
source

Check out the Hudson API .

In particular: you can add /api/[xml|json] to any path in Hudson to get machine-readable data from this page. For example, hudsonserver:8080/api/xml will return a list of tasks and their current statuses.

However, the real question is i, where does this code run? Above is lastBuild and lastCompletedBuild , but where are these variables set?

+2
source

You can try requesting download statistics available in a separate API :

 <overallLoadStatistics> <busyExecutors></busyExecutors> <queueLength></queueLength> <totalExecutors></totalExecutors> <totalQueueLength></totalQueueLength> </overallLoadStatistics> 
+2
source

Are you interested in whether a specific work is being built? In this case:

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

has the <building> set to true if the build is currently in progress.

+2
source

Source: https://habr.com/ru/post/892486/


All Articles