Skip to content

Commit

Permalink
Handle job already scheduled/running
Browse files Browse the repository at this point in the history
  • Loading branch information
iangmaia committed Dec 7, 2023
1 parent 75251a9 commit e67e9e7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/dangermattic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
local METHOD=$1
local BUILDKITE_API_PATH=$2
local BUILDKITE_API_URL="https://api.buildkite.com/v2/organizations/${ORG_SLUG}/pipelines/${PIPELINE_SLUG}/$BUILDKITE_API_PATH"
local BUILDKITE_API_URL="https://api.buildkite.com/v2/organizations/$ORG_SLUG/pipelines/$PIPELINE_SLUG/$BUILDKITE_API_PATH"
local RAW_RESPONSE=$(
curl \
Expand All @@ -39,7 +39,7 @@ jobs:
# Gets the build(s) associated with the latest commit
get_buildkite_build() {
perform_buildkite_request "GET" "builds?commit=${LATEST_COMMIT_SHA}"
perform_buildkite_request "GET" "builds?commit=$LATEST_COMMIT_SHA"
}
# Given a build id ($1) and a job id ($2), retry the given job
Expand Down Expand Up @@ -91,6 +91,8 @@ jobs:
JOB_WEB_URL=$(echo "$BUILDKITE_RETRY_JOB_RESPONSE" | jq -r '.web_url')
echo "✅ Job succesfully retried: $JOB_WEB_URL"
elif [[ "$DANGER_JOB_STATE" == "running" || "$DANGER_JOB_STATE" == "scheduled" ]]; then
echo "⚠️ Job is already in state '$DANGER_JOB_STATE', no need to retry."
else
echo "❌ Cannot retry job in state '$DANGER_JOB_STATE'"
fi

0 comments on commit e67e9e7

Please sign in to comment.