Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .buildkite/pipelines/pull-request-transport-versions.yml
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
steps: []
steps:
- label: update-transport-versions
command: '.buildkite/scripts/update-transport-versions.sh'
# New transport versions are always added via the main branch
if: build.env('BUILDKITE_PULL_REQUEST_BASE_BRANCH') == 'main'
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2404
machineType: custom-16-32768
buildDirectory: /dev/shm/bk
51 changes: 51 additions & 0 deletions .buildkite/scripts/update-transport-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -euo pipefail

if [[ -z "${BUILDKITE_PULL_REQUEST:-}" ]]; then
echo "Not a pull request, skipping transport version update"
exit 0
fi

if ! git diff --exit-code; then
echo "Changes are present before updating transport versions, not running"
git status
exit 0
fi

NEW_COMMIT_MESSAGE="[CI] Update transport version definitions"

echo "--- Generating updated transport version definitions"
# Calculate backport branches based on pull request version labels
backport_branches=$(
echo "${GITHUB_PR_LABELS}" \
| tr ',' '\n' \
| grep -E "v[0-9]+\.[0-9]+\.[0-9]+" \
| sed -E 's/^v([0-9]+)\.([0-9]+)\.[0-9]+$/\1.\2/' \
| paste -sd, -
)

if [[ -z "${backport_branches}" ]]; then
echo "Skipping as pull request contains no version labels"
exit 0
fi

.ci/scripts/run-gradle.sh generateTransportVersion --backport-branches="${backport_branches}"

if git diff --exit-code; then
echo "No changes found after updating transport versions. Don't need to auto commit."
exit 0
fi

git config --global user.name elasticsearchmachine
git config --global user.email '[email protected]'

gh pr checkout "${BUILDKITE_PULL_REQUEST}"
git add -A .
git commit -m "$NEW_COMMIT_MESSAGE"
git push

# After the git push, the new commit will trigger a new build within a few seconds and this build should get cancelled
# So, let's just sleep to give the build time to cancel itself without an error
# If it doesn't get cancelled for some reason, then exit with an error, because we don't want this build to be green (we just don't want it to generate an error either)
sleep 300
exit 1