Introduction:
If you need to find out which pipelines are in-progress without using the UI, you'll find that unlike jobs and workflows, pipelines never have a "running" status.
For pipelines, the possible statuses (returned by the API v2) are: "created" "errored" "setup-pending" "setup" "pending".
However, we can deduce/consider that a given pipeline is in progress if any of the elements (workflows/jobs) it contains are in a "running" state.
Prerequisites (If Applicable):
If you don't already have one that you can use, you'll need to generate a personal API token to authenticate your requests to the CircleCI API v2.
Instructions:
-
Get the list of all pipelines for the project
- Use the "Get all pipelines" endpoint and extract (using a tool like `jq`) the IDs of pipelines with a status different than "errored". Make sure to go through all pages by checking the `next_page_token` in each response.
-
Check the statuses of the workflow(s) for each pipeline
- Using the "Get a pipeline's workflows" endpoint, iterate over each of these pipeline IDs to check the respective statuses of the workflow(s) each pipeline contains.
Outcome:
If for a given pipeline there is [are] a "running" workflow[s], then note/save the pipeline ID; the related pipeline is considered in-progress.
Comments
Article is closed for comments.