Skip to content

Commit 049ec16

Browse files
committed
exit without pipeline upload for empty/failure; consider snapshots too
1 parent 8b74368 commit 049ec16

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

.buildkite/scripts/get-bc-commit.sh

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,46 @@
1111

1212
set -euo pipefail
1313

14-
#TODO: all current branches? Only the "last" one? (9.0 in this case?)
15-
#source .buildkite/scripts/branches.sh
16-
#for BRANCH in "${BRANCHES[@]}"; do
17-
18-
BRANCH=9.0
19-
14+
# Select the most recent build from the current branch.
15+
# We collect snapshots, order by date, then collect BCs, order by date, and concat them; then we select the last.
16+
# So if we have one (or more) BC, we will always prefer to use that. Otherwise we will use the latest snapshot.
2017
MANIFEST="$(curl -s https://artifacts.elastic.co/releases/TfEVhiaBGqR64ie0g0r0uUwNAbEQMu1Z/future-releases/stack.json |
2118
jq ".releases[] |
22-
select(.branch == \"$BRANCH\") |
19+
select(.branch == \"$BUILDKITE_BRANCH\") |
2320
select(.active_release == true) |
24-
.build_candidates |
25-
to_entries |
26-
sort_by(.value.completed_at) |
27-
last |
28-
.value.manifest_url")"
29-
30-
BC_COMMIT_HASH="$(eval "curl -s $MANIFEST" | jq .projects.elasticsearch.commit_hash)"
31-
32-
echo "steps:
33-
- group: bc
34-
steps:
35-
- label: $BRANCH / bc-bwc
36-
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints -Dtests.bwc.main.version=9.1.0 -Dtests.bwc.refspec.main=$BC_COMMIT_HASH -Dtests.jvm.argline=\"-Des.serverless_transport=true\"
37-
timeout_in_minutes: 300
38-
agents:
39-
provider: gcp
40-
image: family/elasticsearch-ubuntu-2004
41-
machineType: n1-standard-32
42-
buildDirectory: /dev/shm/bk
43-
preemptible: true
44-
retry:
45-
automatic:
46-
- exit_status: \"-1\"
47-
limit: 3
48-
signal_reason: none
49-
- signal_reason: agent_stop
50-
limit: 3
51-
"
21+
((.snapshots | to_entries | sort_by(.value.completed_at)) +
22+
(.build_candidates | to_entries | sort_by(.value.completed_at))) |
23+
last | .value.manifest_url")"
24+
25+
if [[ -z "$MANIFEST" ]]; then
26+
echo "No snapshots or build candidates for branch [$BUILDKITE_BRANCH]"
27+
exit 0
28+
fi
29+
30+
31+
TARGET_COMMIT_HASH="$(eval "curl -s $MANIFEST" | jq .projects.elasticsearch.commit_hash)"
32+
33+
if [[ -z "$TARGET_COMMIT_HASH" ]]; then
34+
echo "Cannot get the elasticsearch commit hash from [$MANIFEST]"
35+
exit 1
36+
fi
37+
38+
cat <<EOF | buildkite-agent pipeline upload
39+
steps:
40+
- label: $BUILDKITE_BRANCH / bc-bwc
41+
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints -Dtests.bwc.main.version=9.1.0 -Dtests.bwc.refspec.main=${TARGET_COMMIT_HASH} -Dtests.jvm.argline=\"-Des.serverless_transport=true\"
42+
timeout_in_minutes: 300
43+
agents:
44+
provider: gcp
45+
image: family/elasticsearch-ubuntu-2004
46+
machineType: n1-standard-32
47+
buildDirectory: /dev/shm/bk
48+
preemptible: true
49+
retry:
50+
automatic:
51+
- exit_status: \"-1\"
52+
limit: 3
53+
signal_reason: none
54+
- signal_reason: agent_stop
55+
limit: 3
56+
EOF

0 commit comments

Comments
 (0)