CircleCI Ideas

API listing latest workflows

Cicle 2.0 is a great step forward, but the lack of API limits what we can do with workflows. It implies that we need to make a great deal of processing the jobs result to find the status of the Workflow (If all the steps succeeded, how log the whole workflow took, etc)

Ideally it would work Similarly to the the already existing API endpoint
https://circleci.com/docs/api/#recent-builds-for-a-single-project

curl https://circleci.com/api/v1.1/project/:vcs-type/:username/:project?circle-token=:token&limit=20&offset=5&filter=completed

 

Having the same for workflows, and their basic details / status.

curl https://circleci.com/api/v1.1/project/:vcs-type/:username/:project/workflows?circle-token=:token&limit=20&offset=5&filter=completed


To get what is found in this page:

https://circleci.com/gh/:organization/workflows

{
  "status": "running"
  "jobs" : {
     "job_one": {
          "status": "running"
      },
      "job_two" {
          "status": "dependecy_waiting"
     }
...
   }
}



  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Nov 7 2018
  • Taking votes
API
  • Attach files
  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    24 Jan 00:19

    so important. please?

  • Admin
    Nathan Dintenfass commented
    31 Jul 05:44

    The v2 API, now in public preview, has a way to list recent pipelines by project, which would let you drill in to get workflows too. https://github.com/CircleCI-Public/api-preview-docs

  • Avatar40.8f183f721a2c86cd98fddbbe6dc46ec9
    Guest commented
    08 Aug 14:53
    The v2 API, now in public preview, has a way to list recent pipelines by project, which would let you drill in to get workflows too

    That's true, but it requires multiple round-trips to the CircleCI API, to then look up details of the Pipeline, so you can look up details of the Workflow(s). The ability to directly fetch "recent" Workflows for a Project, including the ability to filter that by Branch and status, would be fantastic and enable building Orbs to do things like:

    • Have a Workflow cancel itself if it's "in between" an actively running Workflow and a later Workflow. (e.g., avoid "Stacked Deploys")
    • A Workflow could cancel itself if another Workflow comes in close behind it as a sort of "debounce" to help prevent "Stacked Deploys"
    • Ensuring only a single Workflow is running at a time, e.g.  https://github.com/eddiewebb/circleci-queue
  • Admin
    Nathan Dintenfass commented
    08 Aug 23:09

    The roundtrips are likely not going away in the v2 API because gathering all the data for each workflow would be too “expensive” on each call. It’s not an ideal experience, but it should be expressive enough to do what you need and can be wrapped into a script fairly easily. An orb that encapsulates that complexity is definitely a good idea.