Skip to content

fix(ci): install mage via asdf if missing in pre-command hook#49776

Closed
orestisfl wants to merge 1 commit intoelastic:mainfrom
orestisfl:fix/asdf-mage-install
Closed

fix(ci): install mage via asdf if missing in pre-command hook#49776
orestisfl wants to merge 1 commit intoelastic:mainfrom
orestisfl:fix/asdf-mage-install

Conversation

@orestisfl
Copy link
Copy Markdown
Contributor

@orestisfl orestisfl commented Mar 30, 2026

Proposed commit message

This PR adds a guard in .buildkite/hooks/pre-command to asdf install mage the required version if missing.

Checklist

  • 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

Related issues

The CI agent image (ci-agent-images) hardcodes mage 1.14.0, but all
beats pipelines set ASDF_MAGE_VERSION: 1.15.0. The agent-level
pre-command hook auto-installs Go, Python, and Node.js when missing
but has no equivalent block for mage.

Add an asdf install guard in the repo pre-command hook to ensure the
required mage version is present before any step runs.
@orestisfl orestisfl self-assigned this Mar 30, 2026
@orestisfl orestisfl requested a review from a team as a code owner March 30, 2026 12:59
@orestisfl orestisfl added bug automation ci backport-active-all Automated backport with mergify to all the active branches labels Mar 30, 2026
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Mar 30, 2026
@botelastic
Copy link
Copy Markdown

botelastic bot commented Mar 30, 2026

This pull request doesn't have a Team:<team> label.

@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

A pre-command hook step was added to .buildkite/hooks/pre-command. The step checks whether ASDF_MAGE_VERSION is set and the asdf tool is available. When both conditions are met, it executes asdf install mage "$ASDF_MAGE_VERSION" to install the specified mage version prior to CPU and platform detection. The change adds 5 lines and modifies no exported or public entity declarations.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.buildkite/hooks/pre-command (1)

31-34: Consider adding a Buildkite step separator for visibility.

Other operations in this file use echo "--- ..." format (e.g., line 26). Adding one here would make the mage installation visible in Buildkite logs.

💡 Suggested change
 # Ensure the required mage version is installed (the CI agent image may not have it)
 if [[ -n "${ASDF_MAGE_VERSION:-}" ]] && command -v asdf &>/dev/null; then
+    echo "--- Installing mage ${ASDF_MAGE_VERSION} via asdf"
     asdf install mage "$ASDF_MAGE_VERSION"
 fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.buildkite/hooks/pre-command around lines 31 - 34, Add a Buildkite step
separator before the mage install so the installation is visible in logs: insert
an echo '--- Installing mage' (or similar) immediately before the block that
checks ASDF_MAGE_VERSION and runs command -v asdf, so the step around the
existing asdf install mage "$ASDF_MAGE_VERSION" is clearly labeled in the
Buildkite output.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.buildkite/hooks/pre-command:
- Around line 31-35: The change adds an asdf-based mage install in the
pre-command hook but lacks a changelog fragment; generate a fragment using the
elastic-agent-changelog-tool (run: go install
github.com/elastic/elastic-agent-changelog-tool@latest and
elastic-agent-changelog-tool new "Install mage via asdf if missing in
pre-command hook"), place the generated file under changelog/fragments/, and set
metadata kind: bug-fix and component: ci (or appropriate component) so the PR
includes the required changelog entry referencing the pre-command hook change
that installs mage when ASDF_MAGE_VERSION is set.

---

Nitpick comments:
In @.buildkite/hooks/pre-command:
- Around line 31-34: Add a Buildkite step separator before the mage install so
the installation is visible in logs: insert an echo '--- Installing mage' (or
similar) immediately before the block that checks ASDF_MAGE_VERSION and runs
command -v asdf, so the step around the existing asdf install mage
"$ASDF_MAGE_VERSION" is clearly labeled in the Buildkite output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2a4587e4-24fd-4b12-bd8f-5afe1dabaccb

📥 Commits

Reviewing files that changed from the base of the PR and between e92763f and ef8c181.

📒 Files selected for processing (1)
  • .buildkite/hooks/pre-command

Comment on lines +31 to +35
# Ensure the required mage version is installed (the CI agent image may not have it)
if [[ -n "${ASDF_MAGE_VERSION:-}" ]] && command -v asdf &>/dev/null; then
asdf install mage "$ASDF_MAGE_VERSION"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing changelog fragment.

This bug fix should include a changelog fragment in changelog/fragments/. Create one via:

go install github.com/elastic/elastic-agent-changelog-tool@latest
elastic-agent-changelog-tool new "Install mage via asdf if missing in pre-command hook"

Set kind: bug-fix and component: ci (or appropriate component). Based on learnings from this repository.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.buildkite/hooks/pre-command around lines 31 - 35, The change adds an
asdf-based mage install in the pre-command hook but lacks a changelog fragment;
generate a fragment using the elastic-agent-changelog-tool (run: go install
github.com/elastic/elastic-agent-changelog-tool@latest and
elastic-agent-changelog-tool new "Install mage via asdf if missing in
pre-command hook"), place the generated file under changelog/fragments/, and set
metadata kind: bug-fix and component: ci (or appropriate component) so the PR
includes the required changelog entry referencing the pre-command hook change
that installs mage when ASDF_MAGE_VERSION is set.

@orestisfl orestisfl closed this Mar 30, 2026
@orestisfl orestisfl deleted the fix/asdf-mage-install branch March 30, 2026 13:34
@orestisfl
Copy link
Copy Markdown
Contributor Author

Closing to handle on the image instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation backport-active-all Automated backport with mergify to all the active branches bug ci needs_team Indicates that the issue/PR needs a Team:* label skip-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants