Skip to content

Commit 57bdcbf

Browse files
authored
[8.19] (backport #8444) bk(docker-login): use BK plugin (#8477)
1 parent 288b1ab commit 57bdcbf

12 files changed

+19
-38
lines changed

.buildkite/bk.integration-fips.pipeline.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
22

33
env:
4-
DOCKER_REGISTRY: "docker.elastic.co"
54
ASDF_MAGE_VERSION: 1.14.0
65

76
IMAGE_UBUNTU_2404_X86_64: "platform-ingest-elastic-agent-ubuntu-2404-1749258065"
@@ -26,6 +25,9 @@ steps:
2625
provider: "gcp"
2726
machineType: "n1-standard-8"
2827
image: "${IMAGE_UBUNTU_2404_X86_64}"
28+
plugins:
29+
- elastic/vault-docker-login#v0.5.2:
30+
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
2931

3032
- label: Start ESS stack for FIPS integration tests
3133
key: integration-fips-ess

.buildkite/bk.integration.pipeline.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
22

33
env:
4-
DOCKER_REGISTRY: "docker.elastic.co"
54
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
65
ASDF_MAGE_VERSION: 1.14.0
76

.buildkite/hooks/pre-command

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,11 @@ if [[ -z "${GO_VERSION-""}" ]]; then
1313
export GO_VERSION=$(cat "${WORKSPACE}/.go-version")
1414
fi
1515

16-
DOCKER_REGISTRY="docker.elastic.co"
17-
DOCKER_REGISTRY_SECRET_PATH="kv/ci-shared/platform-ingest/docker_registry_prod"
1816
CI_DRA_ROLE_PATH="kv/ci-shared/release/dra-role"
1917
CI_GCP_OBS_PATH="kv/ci-shared/observability-ingest/cloud/gcp"
2018
CI_ESS_PATH="kv/ci-shared/platform-ingest/platform-ingest-ec-prod"
2119
CI_DRA_ROLE_PATH="kv/ci-shared/release/dra-role"
2220

23-
24-
function docker_login {
25-
DOCKER_USERNAME_SECRET=$(retry 5 vault kv get -field user "${DOCKER_REGISTRY_SECRET_PATH}")
26-
DOCKER_PASSWORD_SECRET=$(retry 5 vault kv get -field password "${DOCKER_REGISTRY_SECRET_PATH}")
27-
docker login -u "${DOCKER_USERNAME_SECRET}" -p "${DOCKER_PASSWORD_SECRET}" "${DOCKER_REGISTRY}" 2>/dev/null
28-
unset DOCKER_USERNAME_SECRET DOCKER_PASSWORD_SECRET
29-
}
30-
3121
function release_manager_login {
3222
DRA_CREDS_SECRET=$(retry 5 vault kv get -field=data -format=json ${CI_DRA_ROLE_PATH})
3323
VAULT_ADDR_SECRET=$(echo ${DRA_CREDS_SECRET} | jq -r '.vault_addr')
@@ -37,10 +27,6 @@ function release_manager_login {
3727
}
3828

3929
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-package" ]]; then
40-
if [[ "$BUILDKITE_STEP_KEY" == "package_elastic-agent" ]]; then
41-
docker_login
42-
fi
43-
4430
if [[ "$BUILDKITE_STEP_KEY" == "dra-publish" || "$BUILDKITE_STEP_KEY" == "bk-api-publish-independent-agent" ]]; then
4531
release_manager_login
4632
fi
@@ -61,19 +47,9 @@ if [[ "$BUILDKITE_STEP_KEY" == *"integration-tests"* ]]; then
6147
fi
6248

6349
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-binary-dra" ]]; then
64-
if command -v docker &>/dev/null; then
65-
docker_login
66-
else
67-
echo "+++ docker not found"
68-
fi
6950
if [[ ("$BUILDKITE_STEP_KEY" == "publish-dra-snapshot" || "$BUILDKITE_STEP_KEY" == "publish-dra-staging") ]]; then
7051
echo "+++ Setting DRA params"
7152
# Shared secret path containing the dra creds for project teams
7253
release_manager_login
7354
fi
7455
fi
75-
76-
# BUILDKITE_PIPELINE_SLUG should match elastic-agent for PRs, and elastic-agent-extended-tests once it has merged to main
77-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent"* && "$BUILDKITE_STEP_KEY" == "integration-fips-cloud-image" ]]; then
78-
docker_login
79-
fi

.buildkite/hooks/pre-exit

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,3 @@ if [ -n "$TEST_INTEG_AUTH_GCP_SERVICE_TOKEN_FILE" ]; then
2525
rm $TEST_INTEG_AUTH_GCP_SERVICE_TOKEN_FILE
2626
fi
2727
fi
28-
29-
if command -v docker &>/dev/null; then
30-
DOCKER_REGISTRY="docker.elastic.co"
31-
docker logout $DOCKER_REGISTRY
32-
fi

.buildkite/integration.pipeline.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
22

33
env:
4-
DOCKER_REGISTRY: "docker.elastic.co"
54
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
65

76
steps:

.buildkite/pipeline.elastic-agent-binary-dra.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ env:
77
DRA_PROJECT_ID: "elastic-agent-core"
88
DRA_PROJECT_ARTIFACT_ID: "agent-core"
99

10+
# This section is used to define the plugins that will be used in the pipeline.
11+
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
12+
common:
13+
- docker_login_plugin: &docker_login_plugin
14+
elastic/vault-docker-login#v0.5.2:
15+
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
16+
1017
steps:
1118
- group: ":beats: DRA Elastic-Agent Core Snapshot :beats:"
1219
key: "dra-core-snapshot"
@@ -84,6 +91,8 @@ steps:
8491
machineType: "c2-standard-16"
8592
env:
8693
DRA_WORKFLOW: "snapshot"
94+
plugins:
95+
- *docker_login_plugin
8796

8897
- label: ":hammer: Publish helm chart snapshot"
8998
trigger: elastic-agent-helm-charts
@@ -177,6 +186,8 @@ steps:
177186
machineType: "c2-standard-16"
178187
env:
179188
DRA_WORKFLOW: "staging"
189+
plugins:
190+
- *docker_login_plugin
180191

181192
notify:
182193
- slack: "#ingest-notifications"

.buildkite/pipeline.elastic-agent-gce-cleanup.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# See gce-cleanup.sh and .buildkite/misc/gce-cleanup.yml
55
env:
66
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
7-
DOCKER_REGISTRY: "docker.elastic.co"
87
steps:
98
- label: "GCE Cleanup"
109
key: "gce-cleanup"

.buildkite/pipeline.elastic-agent-package.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
22
env:
3-
DOCKER_REGISTRY: "docker.elastic.co"
43
# this is required in order to allow the build process to override the default PWD of the BEAT_NAME.
54
BEAT_NAME: "elastic-agent"
65
# after moving elastic-agent out of beats, we should update the URL of the packaging.
@@ -82,6 +81,10 @@ steps:
8281
fips:
8382
- false
8483
- true
84+
plugins:
85+
- elastic/vault-docker-login#v0.5.2:
86+
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
87+
8588
- label: ":package: FIPS={{matrix.fips}} Package ARM elastic-agent"
8689
key: package_elastic-agent-arm
8790
agents:

.buildkite/pipeline.integration-test-matrix.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
22

33
env:
4-
DOCKER_REGISTRY: "docker.elastic.co"
54
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
65

76
steps:

.buildkite/pipeline.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
env:
44
VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp"
5-
DOCKER_REGISTRY: "docker.elastic.co"
65

76
# The following images are defined here and their values will be updated by updatecli
87
# Please do not change them manually.

0 commit comments

Comments
 (0)