Skip to content

Commit 31a5e1c

Browse files
committed
fix rookie mistake
1 parent e01aafd commit 31a5e1c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.buildkite/scripts/check_queue.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/bin/bash
22

3-
last_build_url="https://api.buildkite.com/v2/organizations/elastic/pipelines/${BUILDKITE_PIPELINE_SLUG}/builds?branch=${BUILDKITE_BRANCH}"
3+
build_data_url="https://api.buildkite.com/v2/organizations/elastic/pipelines/${BUILDKITE_PIPELINE_SLUG}/builds?branch=${BUILDKITE_BRANCH}"
44
cancel_build_url="https://api.buildkite.com/v2/organizations/elastic/pipelines/${BUILDKITE_PIPELINE_SLUG}/builds/${BUILDKITE_JOB_ID}/cancel"
55

66
# Don't look at this build (it's running now!)
77
# Don't look at the last build (it's okay if it's still running!)
88
# Look three builds back instead (if this build is still running,
99
# it means there's already one in the queue and we can safely cancel this one)
10-
THIRD_TO_LAST_BUILD_STATE=$(curl -s -H "Authorization: Bearer ${BUILDKITE_API_TOKEN}" $last_successful_build_url | jq -r '.[2].status')
10+
THIRD_TO_LAST_BUILD_STATE=$(curl -s -H "Authorization: Bearer ${BUILDKITE_API_TOKEN}" $build_data_url | jq -r '.[2].status')
11+
12+
echo $(curl -s -H "Authorization: Bearer ${BUILDKITE_API_TOKEN}" $build_data_url)
1113

1214
echo "Determining if there are multiple builds waiting."
1315
if [[ "$THIRD_TO_LAST_BUILD_STATE" == "running" ]]; then

0 commit comments

Comments
 (0)