pycontribs / jenkinsapi

A Python API for accessing resources and configuring Hudson & Jenkins continuous-integration servers
http://pypi.python.org/pypi/jenkinsapi
MIT License
858 stars 485 forks source link

Get jobs by build status #759

Open driscollis opened 4 years ago

driscollis commented 4 years ago
ISSUE TYPE
Jenkins VERSION

Latest

SUMMARY

I would like a way to ask Jenkins for a filtered list of jobs based on the build's status. For example, I would like to get all jobs where the build status was 'ABORTED' or 'UNSTABLE' versus 'SUCCESS'.

I know Jenkins knows which jobs have failed, but I don't see a good way to ask for just that information using jenkinsapi. I currently wrote a loop to loop over all the jobs in a view and check the job's build status, but that is really clunky and takes a long time since I have to query all the jobs.

lechat commented 4 years ago

AFAIK, there is no way of achieving that using REST API because there is no way to filter output. So loop is the only way to do that and I don't think that jenkinsapi should do that for you.

driscollis commented 4 years ago

That's interesting as Jenkin's itself will show you which jobs have failed (i.e. yellow dots versus blue dots) in a view. I'm surprised they don't expose that.

Iterating over hundreds of builds is really slow though. I can probably just go to a view's page and use BeautifulSoup to extract the tooltip / alt tag and maybe parse out the Unstable jobs that way