API to see if a project (branch) is green?


#1

How do I check if a project branch is currently green? (No failures)

I have looked at https://circleci.com/docs/api under Recent Builds For a Single Project and the “status” field, but when I try say curl 'https://circleci.com/api/v1/project/rocky/libcdio-paranoia?&limit=20&offset=5&filter=completed' I getting a list and the status shows “failure” which is probably a failure somewhere along the way, but I am only interested in the latest build.


#2

The call you’re using now will return the last 20 builds (limit=20). Can you try this one?

curl 'https://circleci.com/api/v1/project/rocky/libcdio-paranoia?&limit=1&filter=completed'

That should return only the most recent, completed build for your project. Then you can determine if it failed or not.

I hope that helps.


#3

That makes sense - will try. Thanks!


#4