Skip to content

Instantly share code, notes, and snippets.

@takp
Created September 25, 2025 06:07
Show Gist options
  • Select an option

  • Save takp/74d9d77e385993d349ac8200d0d5f68a to your computer and use it in GitHub Desktop.

Select an option

Save takp/74d9d77e385993d349ac8200d0d5f68a to your computer and use it in GitHub Desktop.
Cancel GitLab pipelines stacked with "Waiting"
#!/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