1

How do I check in CircleCI if a project branch is currently green (has 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 get a list and the status shows "failure". There was probably a failure somewhere along the way, but I am only interested in the latest build.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
rocky
  • 7,226
  • 3
  • 33
  • 74

1 Answers1

2

You were close. Do

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

and look at the status. Note the limit of 1 instead of 20. That will give you the newest build only.

You can also look at the "failed" property. It is true if the build is red and false if it is green.

rocky
  • 7,226
  • 3
  • 33
  • 74
Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121