-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Remove hardcoded branches from DRA schedule (#15668)
This commit is the first making use of #15627 to remove hard coded branches for the DRA Snapshot build schedule. With this pattern, we will only need to keep `ci/branches.json` up to date, as versions evolve, and not need to update/maintain hard coded branches in `catalog-info.yaml` anymore. Once this is verified working, we'll add a corresponding schedule pipeline (in `catalog.info`) for the JDK matrix job. Relates: elastic/ingest-dev#2664
- Loading branch information
Showing
3 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
.buildkite/scripts/common/trigger-pipeline-generate-steps.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
# ******************************************************* | ||
# this script is used by schedule-type pipelines | ||
# to automate triggering other pipelines (e.g. DRA) based | ||
# on ci/branches.json | ||
# | ||
# See: | ||
# https://elasticco.atlassian.net/browse/ENGPRD-318 / | ||
# https://github.com/elastic/ingest-dev/issues/2664 | ||
# ******************************************************* | ||
|
||
ACTIVE_BRANCHES_URL="https://raw.githubusercontent.com/elastic/logstash/main/ci/branches.json" | ||
|
||
function install_yq() { | ||
if ! [[ -x $(which yq) && $(yq --version) == *mikefarah* ]]; then | ||
echo "--- Downloading prerequisites" | ||
curl -fsSL --retry-max-time 60 --retry 3 --retry-delay 5 -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | ||
chmod a+x /usr/local/bin/yq | ||
fi | ||
} | ||
|
||
if [[ -z $PIPELINE_TO_TRIGGER ]]; then | ||
echo "^^^ +++" | ||
echo "Required environment variable [PIPELINE_TO_TRIGGER] is missing." | ||
echo "Exiting now." | ||
exit 1 | ||
fi | ||
|
||
set -u | ||
set +e | ||
BRANCHES=$(curl --retry-all-errors --retry 5 --retry-delay 5 -fsSL $ACTIVE_BRANCHES_URL | jq -r '.branches[].branch') | ||
if [[ $? -ne 0 ]]; then | ||
echo "There was an error downloading or parsing the json output from [$ACTIVE_BRANCHES_URL]. Exiting." | ||
exit 1 | ||
fi | ||
|
||
set -e | ||
|
||
install_yq | ||
|
||
echo 'steps:' >pipeline_steps.yaml | ||
|
||
for BRANCH in $BRANCHES; do | ||
cat >>pipeline_steps.yaml <<EOF | ||
- trigger: $PIPELINE_TO_TRIGGER | ||
label: ":testexecute: Triggering ${PIPELINE_TO_TRIGGER} / ${BRANCH}" | ||
branches: "main" | ||
async: true | ||
build: | ||
branch: "$BRANCH" | ||
message: ":testexecute: Triggering ${PIPELINE_TO_TRIGGER} / ${BRANCH}" | ||
EOF | ||
done | ||
|
||
echo "--- Printing generated steps" | ||
yq . pipeline_steps.yaml | ||
|
||
echo "--- Uploading steps to buildkite" | ||
cat pipeline_steps.yml | buildkite-agent pipeline upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json | ||
|
||
steps: | ||
- label: ":pipeline: Generate trigger steps for $PIPELINE_TO_TRIGGER" | ||
command: ".buildkite/scripts/trigger-pipeline-generate-steps.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters