Created
September 25, 2025 06:07
-
-
Save takp/74d9d77e385993d349ac8200d0d5f68a to your computer and use it in GitHub Desktop.
Cancel GitLab pipelines stacked with "Waiting"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Simple GitLab pipeline cancel script | |
| # Usage: | |
| # export TOKEN="your_token" | |
| # export PROJECT_ID="your_project_id" | |
| # ./cancel.sh | |
| echo "Canceling waiting_for_resource pipelines..." | |
| # Get pipeline IDs and cancel them | |
| curl -s --header "PRIVATE-TOKEN: $TOKEN" \ | |
| "https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines?status=waiting_for_resource&per_page=100" | \ | |
| jq -r '.[].id' | \ | |
| while read pipeline_id; do | |
| echo "Canceling: Pipeline #$pipeline_id" | |
| curl -s --request POST --header "PRIVATE-TOKEN: $TOKEN" \ | |
| "https://gitlab.com/api/v4/projects/$PROJECT_ID/pipelines/$pipeline_id/cancel" | |
| echo "⏹️ Canceled: #$pipeline_id" | |
| done | |
| echo "🎉 Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment