Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Aug 7, 2025

What does this PR do?

This PR reworks the .package-version file format and integrates it into our CI and mage workflows to enable deterministic, snapshot-based builds of Elastic Agent based on published DRA (Downloadable Release Artifacts).

Key changes:

  • .package-version is now a structured JSON file containing version metadata (version, build_id, stack_build_id, manifest_url, etc.).
  • CI scripts and mage targets now conditionally derive the agent version and build metadata from .package-version when USE_PACKAGE_VERSION=true is set.
  • The mage target UpdatePackageVersion replaces previous logic with a structured update mechanism for .package-version.
  • CI integration steps now consistently use the snapshot version and manifest provided in .package-version.

Why is it important?

We previously had a fundamental dependency issue in the release flow: to produce a new Elastic Agent DRA, we needed to bump the agent version — but our CI integration tests required that same DRA to already exist in order to pass. This created a timing problem and made the release workflow fragile.

With this PR:

  • The CI system and mage targets now honour .package-version when USE_PACKAGE_VERSION=true is set, allowing packaging and testing to rely on a known-good, previously published DRA.
  • This ensures that builds and tests only proceed against DRAs that have been published by the unified release process, making test results and releases more predictable and reliable.
  • PRs such as #9163, which update .package-version, now become the authoritative source of truth for the Elastic Agent version used in the repo and must be handled with utmost care.
  • Note: Even if a component publishes its own DRA, Elastic Agent will only package it once the unified release has run and the respective PR to update the .package-version has been merged.

This enables a reproducible and version-pinned CI system while allowing us to automate snapshot bumps in a controlled and testable way.

An experimental version bump under commit a57ee10 verified this flow successfully. The CI run is available here.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

None expected. Existing workflows are unaffected unless USE_PACKAGE_VERSION=true is explicitly set. In that case, .package-version is required and must be up to date.

How to test this PR locally

specify USE_PACKAGE_VERION=true and call any mage target e.g.

USE_PACKAGE_VERSION="true" EXTERNAL="true" PLATFORMS="linux/arm64" PACKAGES="docker" DOCKER_VARIANTS="basic" mage package

Related issues

  • N/A

This is an automatic backport of pull request #9048 done by [Mergify](https://mergify.com).

* feat: rework .package-version and mage integration:UpdatePackageVersion to make CI build always from snapshot DRA

* feat: incorporate USE_PACKAGE_VERSION in mage

* experiment: bump version.go

* Revert "experiment: bump version.go"

This reverts commit a57ee10.

* chore: bump .package-version

* feat: allow AGENT_VERSION to be overridden by env var

* fix: use named args for all args in integration_tests_tf.ps1

* feat: panic on err of initPackageVersion

* fix: don't panic when .package-version file doesn't exist, log it instead

* feat: rework fabrication of CI_ELASTIC_AGENT_DOCKER_IMAGE

* feat: use os.WriteFile in writePackageVersion

* chore: bump to latest snapshot DRA

* fix: always DownloadManifest if PackagingFromManifest is set in mage package

* fix: check err of filepath.Abs(dropPath)

(cherry picked from commit a155660)

# Conflicts:
#	.buildkite/integration.pipeline.yml
#	.package-version
@mergify mergify bot requested a review from a team as a code owner August 7, 2025 08:45
@mergify mergify bot added backport conflicts There is a conflict in the backported pull request labels Aug 7, 2025
@mergify mergify bot requested a review from a team as a code owner August 7, 2025 08:45
@mergify mergify bot requested review from kaanyalti and removed request for a team August 7, 2025 08:45
@mergify mergify bot added the conflicts There is a conflict in the backported pull request label Aug 7, 2025
@mergify mergify bot requested a review from michel-laterman August 7, 2025 08:45
@mergify mergify bot added the backport label Aug 7, 2025
@mergify
Copy link
Contributor Author

mergify bot commented Aug 7, 2025

Cherry-pick of a155660 has failed:

On branch mergify/bp/9.1/pr-9048
Your branch is up to date with 'origin/9.1'.

You are currently cherry-picking commit a155660c4.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   .buildkite/scripts/buildkite-integration-tests.ps1
	modified:   .buildkite/scripts/buildkite-integration-tests.sh
	modified:   .buildkite/scripts/buildkite-k8s-integration-tests.sh
	modified:   .buildkite/scripts/steps/ess.ps1
	modified:   .buildkite/scripts/steps/ess.sh
	modified:   .buildkite/scripts/steps/ess_start.sh
	new file:   .buildkite/scripts/steps/integration-cloud-image-push.sh
	modified:   .buildkite/scripts/steps/integration-package.sh
	modified:   .buildkite/scripts/steps/integration_tests.sh
	modified:   .buildkite/scripts/steps/integration_tests_tf.ps1
	modified:   .buildkite/scripts/steps/integration_tests_tf.sh
	modified:   .github/workflows/bump-agent-versions.sh
	modified:   dev-tools/mage/manifest/manifest.go
	new file:   dev-tools/mage/packageversion.go
	modified:   dev-tools/mage/settings.go
	modified:   magefile.go
	modified:   test_infra/ess/deployment.tf
	modified:   testing/integration/ess/upgrade_broken_package_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   .buildkite/integration.pipeline.yml
	both modified:   .package-version

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@pkoutsovasilis
Copy link
Contributor

first I wanna see how this PR behaves on main and if everything checks out, I am gonna deal with the backports

@pkoutsovasilis
Copy link
Contributor

ok CI run on main is green and the automation PR looks correct #9283 proceeding with addressing the conflicts

@elastic-sonarqube
Copy link

@elasticmachine
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @pkoutsovasilis

@pkoutsovasilis pkoutsovasilis merged commit 8265e84 into 9.1 Aug 7, 2025
19 checks passed
@pkoutsovasilis pkoutsovasilis deleted the mergify/bp/9.1/pr-9048 branch August 7, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants