Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

Evgeny Goldin
Hi,

We need to periodically restart a Hudson server so we have a simple Groovy script analyzing if Hudson is "busy" before doing so, so that no jobs are killed.

I was able to retrieve a number of currently running jobs with
http://hudson-server/computer/api/xml?xpath=*/busyExecutors/text()

but I couldn't find a way to retrieve the actual list of currently running jobs.

Can it be done?
Thank you!
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

Sami Tikka
We have a script at work that does the same thing. I did not write it
but I think it works by screen-scraping. I can check tomorrow.

Were you aware of the Hudson CLI and its safe-restart command?
Wouldn't that do what you want, only easier?

-- Sami

2010/8/25 Evgeny Goldin <[hidden email]>:

>
> Hi,
>
> We need to periodically restart a Hudson server so we have a simple Groovy
> script analyzing if Hudson is "busy" before doing so, so that no jobs are
> killed.
>
> I was able to retrieve a number of currently running jobs with
> http://hudson-server/computer/api/xml?xpath=*/busyExecutors/text()
> but I couldn't find a way to retrieve the actual list of currently running
> jobs.
>
> Can it be done?
> Thank you!
>
> -----
> Best regards,
> Evgeny
> http://evgeny-goldin.com/
>
> --
> View this message in context: http://hudson.361315.n4.nabble.com/Getting-a-list-of-currently-running-jobs-through-a-Hudson-HTTP-API-XML-JSON-tp2338793p2338793.html
> Sent from the Hudson users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

Andrew Bayer
In reply to this post by Evgeny Goldin
If I recall correctly, this is actually a pain - there's no "get all currently running jobs" method. In the throttle concurrent builds plugin, I have to check for running jobs and it's ugly. It looks like you could theoretically get this from OverallLoadStatistics (via computeIdleExecutors and computeTotalExecutors) but while that's exported (<overallLoad> in the top-level /api/xml) there's nothing actually *in* it. Seems like that might make sense to export.

A.

On Wed, Aug 25, 2010 at 12:46 PM, Evgeny Goldin <[hidden email]> wrote:

Hi,

We need to periodically restart a Hudson server so we have a simple Groovy
script analyzing if Hudson is "busy" before doing so, so that no jobs are
killed.

I was able to retrieve a number of currently running jobs with
http://hudson-server/computer/api/xml?xpath=*/busyExecutors/text()
but I couldn't find a way to retrieve the actual list of currently running
jobs.

Can it be done?
Thank you!

-----
Best regards,
Evgeny
http://evgeny-goldin.com/

--
View this message in context: http://hudson.361315.n4.nabble.com/Getting-a-list-of-currently-running-jobs-through-a-Hudson-HTTP-API-XML-JSON-tp2338793p2338793.html
Sent from the Hudson users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

Evgeny Goldin
In reply to this post by Sami Tikka
In fact, the script checks Hudson status so that it can restart a Tomcat server. When Tomcat is down we do some house cleaning and bring it up right away. So Hudson CLI can solve our problem but only partially.
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

Evgeny Goldin
In reply to this post by Andrew Bayer
Argh .. I was suspecting it can be a pain. I tried peeking in load statistics but didn't see any data there, probably it's not recorded or not activated. Will try again, thank you!
Best regards,
Evgeny
http://evgeny-goldin.com/
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

Evgeny Goldin
Reply | Threaded
Open this post in threaded view
|

Re: Getting a list of currently running jobs through a Hudson HTTP API (XML/JSON)

Sami Tikka
In reply to this post by Sami Tikka
Hi! I checked out the script at work but it is of no help. It does not
check the actual running jobs, only if the number of busy executors is
0.

-- Sami

2010/8/25 Sami Tikka <[hidden email]>:

> We have a script at work that does the same thing. I did not write it
> but I think it works by screen-scraping. I can check tomorrow.
>
> Were you aware of the Hudson CLI and its safe-restart command?
> Wouldn't that do what you want, only easier?
>
> -- Sami
>
> 2010/8/25 Evgeny Goldin <[hidden email]>:
>>
>> Hi,
>>
>> We need to periodically restart a Hudson server so we have a simple Groovy
>> script analyzing if Hudson is "busy" before doing so, so that no jobs are
>> killed.
>>
>> I was able to retrieve a number of currently running jobs with
>> http://hudson-server/computer/api/xml?xpath=*/busyExecutors/text()
>> but I couldn't find a way to retrieve the actual list of currently running
>> jobs.
>>
>> Can it be done?
>> Thank you!
>>
>> -----
>> Best regards,
>> Evgeny
>> http://evgeny-goldin.com/
>>
>> --
>> View this message in context: http://hudson.361315.n4.nabble.com/Getting-a-list-of-currently-running-jobs-through-a-Hudson-HTTP-API-XML-JSON-tp2338793p2338793.html
>> Sent from the Hudson users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]