I need to manually call the api and cancel a job thats on hold, I found the following script from another post in the community but it seems its wrong:
rolling-backward :
executor: node
steps:
- aws-cli/install
- restore_cache:
keys:
- aws-lambda-scripts-v1
- run: |
ls -l
sh ./aws-lambda-scripts/scripts/set-previous-to-full-traffic.sh FUNCTION=lambda-test ALIAS=LATEST PREVIOUS_VERSION=$(./aws-lambda-scripts/scripts/get-previous-version.sh FUNCTION=lambda-test)
- run:
name: Cancelling the other on_hold workflow
command: |
other_on_hold_id=$(curl -G "https://circleci.com/api/v2/pipeline/<<pipeline.id>>/workflow" -H "Circle-Token: $MyToken"|jq -rs --arg CIRCLE_WORKFLOW_ID "$CIRCLE_WORKFLOW_ID" '.[].items[]|select(.status == "on_hold")|select(.id != $CIRCLE_WORKFLOW_ID)|.id')
echo $other_on_hold_id
curl -X POST "https://circleci.com/api/v2/workflow/${other_on_hold_id}/cancel" -H "Circle-Token: ${MyToken}"
the output:
#!/bin/bash -eo pipefail
other_on_hold_id=$(curl -G "https://circleci.com/api/v2/pipeline/353df28d-2961-4bce-89e2-14e4b6c9b002/workflow" -H "Circle-Token: $MyToken")
echo $other_on_hold_id
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 37 100 37 0 0 853 0 --:--:-- --:--:-- --:--:-- 860
{ "message" : "Project not found" }