CircleCI Ideas

Public API to get the last successful build for a specified job

Sometimes I need to get the last successful build for a specified job. Currently I use the API to list builds and filter by jq like below.

$ curl -s "https://circleci.com/api/v1.1/project/:vcs-type/:username/:project?circle-token=:token&limit=100&filter=successful" | jq -r '[.[] | select( .workflows.job_name == ":job_name" )] | max_by(.build_num).stop_time'

But it's complicated and it becomes more difficult in the case that the last successful build for a specified job is not in recent 100 builds. So it will be helpful if there is a public API to get information of the last successful build for a specified job.

FYI, Jenkins has an easy way to retrieve last successful build.

https://stackoverflow.com/questions/31508603/how-to-retrieve-build-id-of-latest-successful-build-in-jenkins

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Nov 16 2018
  • New
API
  • Attach files