Skip to content

Commit f4470f8

Browse files
authored
[8.19](backport #5042) bk: use buildkite plugins (#5103)
1 parent 1c233b8 commit f4470f8

File tree

6 files changed

+36
-39
lines changed

6 files changed

+36
-39
lines changed

.buildkite/hooks/pre-command

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set -euo pipefail
44

55
source .buildkite/scripts/common.sh
66

7-
DOCKER_REGISTRY_SECRET_PATH="kv/ci-shared/platform-ingest/docker_registry_prod"
87
EC_KEY_SECRET_PATH="kv/ci-shared/platform-ingest/platform-ingest-ec-prod"
98
CI_DRA_ROLE_PATH="kv/ci-shared/release/dra-role"
109
JOB_GCS_BUCKET="fleet-server-ci-internal"
@@ -45,14 +44,7 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-package-mbp" ]]; then
4544
check_if_file_exist_in_repo "infra" "${_branch}" #TODO should be changed to "main" for rollback...
4645
fi
4746

48-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" || "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-perf-tests" ]]; then
49-
if [[ "$BUILDKITE_STEP_KEY" == "publish" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-test" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-fips-test" || "$BUILDKITE_STEP_KEY" == "create-image" ]]; then
50-
export DOCKER_USERNAME_SECRET=$(retry 5 vault kv get -field user "${DOCKER_REGISTRY_SECRET_PATH}")
51-
export DOCKER_PASSWORD_SECRET=$(retry 5 vault kv get -field password "${DOCKER_REGISTRY_SECRET_PATH}")
52-
docker login -u "${DOCKER_USERNAME_SECRET}" -p "${DOCKER_PASSWORD_SECRET}" "${DOCKER_REGISTRY}" 2>/dev/null
53-
fi
54-
fi
55-
47+
# TODO: use a builkite plugin to handle this
5648
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" ]]; then
5749
if [[ "$BUILDKITE_STEP_KEY" == "cloud-e2e-test" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-fips-test" ]]; then
5850
export EC_API_KEY_SECRET=$(retry 5 vault kv get -field apiKey "${EC_KEY_SECRET_PATH}")
@@ -61,20 +53,9 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" ]]; then
6153
fi
6254
fi
6355

64-
# BK analytics
65-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" ]]; then
66-
if [[ "$BUILDKITE_STEP_KEY" == "int-test" || "$BUILDKITE_STEP_KEY" == "e2e-test" || "$BUILDKITE_STEP_KEY" == "fips-e2e-test" ]]; then
67-
echo "--- Prepare BK test analytics token :vault:"
68-
BUILDKITE_ANALYTICS_TOKEN=$(vault kv get -field token kv/ci-shared/platform-ingest/buildkite_fleet_server_analytics_token)
69-
export BUILDKITE_ANALYTICS_TOKEN
70-
fi
71-
fi
72-
56+
# TODO: use a builkite plugin to handle this
7357
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-package-mbp" ]]; then
7458
if [[ "$BUILDKITE_STEP_KEY" == "dra-snapshot" || "$BUILDKITE_STEP_KEY" == "dra-staging" ]]; then
75-
export DOCKER_USERNAME_SECRET=$(retry 5 vault kv get -field user "${DOCKER_REGISTRY_SECRET_PATH}")
76-
export DOCKER_PASSWORD_SECRET=$(retry 5 vault kv get -field password "${DOCKER_REGISTRY_SECRET_PATH}")
77-
docker login -u "${DOCKER_USERNAME_SECRET}" -p "${DOCKER_PASSWORD_SECRET}" "${DOCKER_REGISTRY}" 2>/dev/null
7859
DRA_CREDS_SECRET=$(retry 5 vault kv get -field=data -format=json ${CI_DRA_ROLE_PATH})
7960
export VAULT_ADDR_SECRET=$(echo ${DRA_CREDS_SECRET} | jq -r '.vault_addr')
8061
export VAULT_ROLE_ID_SECRET=$(echo ${DRA_CREDS_SECRET} | jq -r '.role_id')

.buildkite/hooks/pre-exit

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ set -euo pipefail
44

55
source .buildkite/scripts/common.sh
66

7-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" || "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-perf-tests" ]]; then
8-
if [[ "$BUILDKITE_STEP_KEY" == "publish" || "$BUILDKITE_STEP_KEY" == "cloud-e2e-test" || "$BUILDKITE_STEP_KEY" == "create-image" ]]; then
9-
docker logout ${DOCKER_REGISTRY}
10-
fi
11-
fi
12-
137
if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server" && "$BUILDKITE_STEP_KEY" == "release-test" ]]; then
148
cleanup
159
fi
@@ -19,7 +13,6 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "fleet-server-package-mbp" ]]; then
1913
unset VAULT_ROLE_ID_SECRET
2014
unset VAULT_ADDR_SECRET
2115
unset VAULT_SECRET_ID_SECRET
22-
docker logout ${DOCKER_REGISTRY}
2316
cleanup
2417
fi
2518
fi

.buildkite/pipeline.package.mbp.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
name: "fleet server package mbp"
33
env:
44
REPO: 'fleet-server'
5-
DOCKER_REGISTRY: "docker.elastic.co"
65
IMAGE_UBUNTU_X86_64: "family/core-ubuntu-2004"
76
IMAGE_UBUNTU_ARM_64: "core-ubuntu-2004-aarch64"
87

.buildkite/pipeline.perf-tests.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
22

33
env:
4-
DOCKER_REGISTRY: "docker.elastic.co"
5-
DOCKER_IMAGE: "${DOCKER_REGISTRY}/observability-ci/fleet-server" # needs to rename for rollback
4+
DOCKER_IMAGE: "docker.elastic.co/observability-ci/fleet-server" # needs to rename for rollback
65
DOCKER_IMAGE_GIT_TAG: "${BUILDKITE_BRANCH}" # needs to rename for rollback
76
DOCKER_IMAGE_LATEST_TAG: "latest" # needs to rename for rollback
87
DOCKER_IMAGE_SHA_TAG: "git-${BUILDKITE_COMMIT:0:12}" # needs to rename for rollback, should be "git-${BUILDKITE_COMMIT:0:12}"
98

9+
# This section is used to define the plugins that will be used in the pipeline.
10+
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
11+
common:
12+
- docker_elastic_login_plugin: &docker_elastic_login_plugin
13+
elastic/vault-docker-login#v0.6.0:
14+
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
15+
1016
steps:
1117
- label: ":docker: Publish docker image"
1218
key: "create-image"
1319
command: ".buildkite/scripts/build_push_docker_image.sh"
1420
agents:
1521
provider: "gcp"
22+
plugins:
23+
- *docker_elastic_login_plugin
1624

1725
- label: "perf test"
1826
key: "obs-perf-test"

.buildkite/pipeline.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ env:
55
TERRAFORM_VERSION: "1.6.4"
66
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-fleet-server-ubuntu-2204-fips-1751684469"
77

8+
# This section is used to define the plugins that will be used in the pipeline.
9+
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
10+
common:
11+
- test_collector_plugin: &test_collector_plugin
12+
test-collector#v1.11.0:
13+
files: "build/test-*.xml"
14+
format: "junit"
15+
branches: "main"
16+
debug: true
17+
- bk_analytics_token_plugin: &bk_analytics_token_plugin
18+
elastic/vault-secrets#v0.1.0:
19+
path: "kv/ci-shared/platform-ingest/buildkite_analytics_token"
20+
field: "token"
21+
env_var: "BUILDKITE_ANALYTICS_TOKEN"
22+
- docker_elastic_login_plugin: &docker_elastic_login_plugin
23+
elastic/vault-docker-login#v0.6.0:
24+
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
25+
826
steps:
927
- group: "Check and build"
1028
key: "check"
@@ -174,7 +192,6 @@ steps:
174192
- label: ":gcloud: Cloud e2e Test"
175193
key: "cloud-e2e-test"
176194
env:
177-
DOCKER_REGISTRY: "docker.elastic.co"
178195
DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fleet"
179196
DOCKER_IMAGE_TAG: "pr-${BUILDKITE_PULL_REQUEST}-${BUILDKITE_COMMIT:0:12}"
180197
SNAPSHOT: "true"
@@ -183,6 +200,8 @@ steps:
183200
command: ".buildkite/scripts/cloud_e2e_test.sh"
184201
agents:
185202
provider: "gcp"
203+
plugins:
204+
- *docker_elastic_login_plugin
186205
depends_on:
187206
- step: "unit-test"
188207
allow_failure: false
@@ -199,7 +218,6 @@ steps:
199218
- label: ":gcloud: Cloud e2e FIPS Test"
200219
key: "cloud-e2e-fips-test"
201220
env:
202-
DOCKER_REGISTRY: "docker.elastic.co"
203221
DOCKER_BASE_IMAGE: "docker.elastic.co/cloud-release/elastic-agent-cloud-fips"
204222
DOCKER_IMAGE: "docker.elastic.co/beats-ci/elastic-agent-cloud-fips"
205223
DOCKER_IMAGE_TAG: "pr-${BUILDKITE_PULL_REQUEST}-${BUILDKITE_COMMIT:0:12}"
@@ -210,6 +228,8 @@ steps:
210228
command: ".buildkite/scripts/cloud_e2e_test.sh"
211229
agents:
212230
provider: "gcp"
231+
plugins:
232+
- *docker_elastic_login_plugin
213233
depends_on:
214234
- step: "unit-test"
215235
allow_failure: false
@@ -227,14 +247,15 @@ steps:
227247
key: "publish"
228248
command: ".buildkite/scripts/build_push_docker_image.sh"
229249
env:
230-
DOCKER_REGISTRY: "docker.elastic.co"
231250
DOCKER_IMAGE: "docker.elastic.co/observability-ci/fleet-server" # needs to rename for rollback
232251
DOCKER_IMAGE_SHA_TAG: "git-${BUILDKITE_COMMIT:0:12}" # needs to rename for rollback, should be "git-${BUILDKITE_COMMIT:0:12}"
233252
DOCKER_IMAGE_LATEST_TAG: "latest" # needs to rename for rollback
234253
DOCKER_IMAGE_GIT_TAG: "${BUILDKITE_BRANCH}" # needs to rename for rollback
235254
if: "build.env('BUILDKITE_PULL_REQUEST') == 'false' && build.env('BUILDKITE_BRANCH') == 'main'"
236255
agents:
237256
provider: "gcp"
257+
plugins:
258+
- *docker_elastic_login_plugin
238259
depends_on:
239260
- step: "tests"
240261
allow_failure: false

.buildkite/scripts/common.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ retry() {
9393
return 0
9494
}
9595

96-
docker_logout() {
97-
echo "Logging out from Docker..."
98-
docker logout ${DOCKER_REGISTRY}
99-
}
100-
10196
with_Terraform() {
10297
echo "Setting up the Terraform environment..."
10398
local path_to_file="${WORKSPACE}/terraform.zip"

0 commit comments

Comments
 (0)