diff --git a/.buildkite/bk.integration.pipeline.yml b/.buildkite/bk.integration.pipeline.yml index 5951f9f39b8..8111a5f3fc6 100644 --- a/.buildkite/bk.integration.pipeline.yml +++ b/.buildkite/bk.integration.pipeline.yml @@ -12,6 +12,9 @@ env: IMAGE_DEBIAN_12: "platform-ingest-elastic-agent-debian-12-1750467641" IMAGE_WIN_2022: "platform-ingest-elastic-agent-windows-2022-1750467641" IMAGE_WIN_2025: "platform-ingest-elastic-agent-windows-2025-1750467641" + # Remove AGENT_VERSION pinning once 8.18.4 DRA and stack are released + AGENT_VERSION: "8.18.3-SNAPSHOT" + # This section is used to define the plugins that will be used in the pipeline. # See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins diff --git a/.buildkite/integration.pipeline.yml b/.buildkite/integration.pipeline.yml index 8a158addfe2..d90e5678cbc 100644 --- a/.buildkite/integration.pipeline.yml +++ b/.buildkite/integration.pipeline.yml @@ -2,6 +2,9 @@ env: VAULT_PATH: "kv/ci-shared/observability-ingest/cloud/gcp" + # Remove AGENT_PACKAGE_VERSION and AGENT_VERSION pinning once 8.18.4 DRA and stack are released + AGENT_PACKAGE_VERSION: "8.18.3" + BEAT_VERSION: "8.18.3" steps: - group: "Integration tests: packaging" diff --git a/.buildkite/scripts/buildkite-integration-tests.ps1 b/.buildkite/scripts/buildkite-integration-tests.ps1 index d96c1439ad6..86b7d39c41a 100644 --- a/.buildkite/scripts/buildkite-integration-tests.ps1 +++ b/.buildkite/scripts/buildkite-integration-tests.ps1 @@ -25,9 +25,11 @@ go install gotest.tools/gotestsum gotestsum --version $env:TEST_BINARY_NAME = "elastic-agent" -# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925 -$AGENT_VERSION = (Get-Content version/version.go | Select-String -Pattern 'const defaultBeatVersion =' | ForEach-Object { $_ -replace '.*?"(.*?)".*', '$1' }) -$env:AGENT_VERSION = $AGENT_VERSION + "-SNAPSHOT" +if (-not $env:AGENT_VERSION) { + # Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925 + $AGENT_VERSION = (Get-Content version/version.go | Select-String -Pattern 'const defaultBeatVersion =' | ForEach-Object { $_ -replace '.*?"(.*?)".*', '$1' }) + $env:AGENT_VERSION = $AGENT_VERSION + "-SNAPSHOT" +} Write-Output "~~~ Agent version: $env:AGENT_VERSION" $env:SNAPSHOT = $true diff --git a/.buildkite/scripts/buildkite-integration-tests.sh b/.buildkite/scripts/buildkite-integration-tests.sh index 6f1524bde31..36017a5ee8c 100755 --- a/.buildkite/scripts/buildkite-integration-tests.sh +++ b/.buildkite/scripts/buildkite-integration-tests.sh @@ -32,9 +32,12 @@ echo "~~~ Running integration tests as $USER" make install-gotestsum -# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925 -AGENT_VERSION=$(grep "const defaultBeatVersion =" version/version.go | cut -d\" -f2) -AGENT_VERSION="${AGENT_VERSION}-SNAPSHOT" +if [[ -z "${AGENT_VERSION:-}" ]]; then + # Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925 + AGENT_VERSION=$(grep "const defaultBeatVersion =" version/version.go | cut -d\" -f2) + AGENT_VERSION="${AGENT_VERSION}-SNAPSHOT" +fi + export AGENT_VERSION echo "~~~ Agent version: ${AGENT_VERSION}" diff --git a/.buildkite/scripts/common.sh b/.buildkite/scripts/common.sh index 97b3a3a4904..3074a839009 100755 --- a/.buildkite/scripts/common.sh +++ b/.buildkite/scripts/common.sh @@ -9,8 +9,11 @@ fi if [[ -z "${SETUP_GVM_VERSION-""}" ]]; then SETUP_GVM_VERSION="v0.5.2" # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151 fi -BEAT_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' "${WORKSPACE}/version/version.go") -export BEAT_VERSION + +if [[ -z "${BEAT_VERSION-""}" ]]; then + BEAT_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+(\-[a-zA-Z]+[0-9]+)?' "${WORKSPACE}/version/version.go") + export BEAT_VERSION +fi getOSOptions() { case $(uname | tr '[:upper:]' '[:lower:]') in diff --git a/magefile.go b/magefile.go index cfd43fa9f26..1ac78837af0 100644 --- a/magefile.go +++ b/magefile.go @@ -880,41 +880,37 @@ func (Cloud) Image(ctx context.Context) { // Push builds a cloud image tags it correctly and pushes to remote image repo. // Previous login to elastic registry is required! func (Cloud) Push() error { - snapshot := os.Getenv(snapshotEnv) - defer os.Setenv(snapshotEnv, snapshot) - - os.Setenv(snapshotEnv, "true") + agentVersion, err := mage.AgentPackageVersion() + if err != nil { + return fmt.Errorf("failed to get agent package version: %w", err) + } - version := getVersion() - var tag string + var targetTag string if envTag, isPresent := os.LookupEnv("CUSTOM_IMAGE_TAG"); isPresent && len(envTag) > 0 { - tag = envTag + targetTag = envTag } else { - commit := dockerCommitHash() - time := time.Now().Unix() - - tag = fmt.Sprintf("%s-%s-%d", version, commit, time) + targetTag = fmt.Sprintf("%s-%s-%d", agentVersion, dockerCommitHash(), time.Now().Unix()) } - sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s", version) + sourceCloudImageName := fmt.Sprintf("docker.elastic.co/beats-ci/elastic-agent-cloud:%s-SNAPSHOT", agentVersion) var targetCloudImageName string if customImage, isPresent := os.LookupEnv("CI_ELASTIC_AGENT_DOCKER_IMAGE"); isPresent && len(customImage) > 0 { - targetCloudImageName = fmt.Sprintf("%s:%s", customImage, tag) + targetCloudImageName = fmt.Sprintf("%s:%s", customImage, targetTag) } else { - targetCloudImageName = fmt.Sprintf(cloudImageTmpl, tag) + targetCloudImageName = fmt.Sprintf(cloudImageTmpl, targetTag) } fmt.Printf(">> Setting a docker image tag to %s\n", targetCloudImageName) - err := sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName) + err = sh.RunV("docker", "tag", sourceCloudImageName, targetCloudImageName) if err != nil { - return fmt.Errorf("Failed setting a docker image tag: %w", err) + return fmt.Errorf("failed setting a docker image tag: %w", err) } fmt.Println(">> Docker image tag updated successfully") fmt.Println(">> Pushing a docker image to remote registry") err = sh.RunV("docker", "image", "push", targetCloudImageName) if err != nil { - return fmt.Errorf("Failed pushing docker image: %w", err) + return fmt.Errorf("failed pushing docker image: %w", err) } fmt.Printf(">> Docker image pushed to remote registry successfully: %s\n", targetCloudImageName) diff --git a/testing/integration/ess/upgrade_broken_package_test.go b/testing/integration/ess/upgrade_broken_package_test.go index c2b348ea87a..776646f8037 100644 --- a/testing/integration/ess/upgrade_broken_package_test.go +++ b/testing/integration/ess/upgrade_broken_package_test.go @@ -32,6 +32,7 @@ func TestUpgradeBrokenPackageVersion(t *testing.T) { Local: false, // requires Agent installation Sudo: true, // requires Agent installation }) + t.Skip("Skip this test until elastic agent version pinning is removed from Integration test runs on CI") ctx, cancel := testcontext.WithDeadline(t, context.Background(), time.Now().Add(10*time.Minute)) defer cancel()