tl;dr: How do I get all the workflows for all the branches in a repository?
I’m trying to do some analysis on workflows for a particular repository. I’ve found I can list out the workflows that run on the default branch with:
curl -XGET "https://circleci.com/api/v2/insights/${PROJECT_SLUG}/workflows?circle-token=${CIRCLECI_TOKEN}"
But that doesn’t cover all the branches, and some workflows only run on certain branches. I don’t want to have to know all the branches and workflows for a project to list all the workflows that have run. I tried listing all the pipelines that have run with:
curl -XGET "https://circleci.com/api/v2/project/${PROJECT_SLUG}/pipeline?circle-token=${CIRCLECI_TOKEN}&branch=staging"
But can’t correlate them with a workflow like the documentation implies I should be able to:
$ BASE="https://circleci.com/api/v2/project/${PROJECT_SLUG}/pipeline" \
> && PIPELINE_ID="$(curl -XGET "${BASE}?circle-token=${CIRCLECI_TOKEN}" | jq -r '.items | first(.[]) | .id')" \
> && curl -XGET "${BASE}/${PIPELINE_ID}/workflow?circle-token=${CIRCLECI_TOKEN}"
{
"message" : "Not Found"
}
Is the documentation at https://circleci.com/docs/api/v2/#get-a-pipeline-39-s-workflows incorrect?