fix(ci): install mage via asdf if missing in pre-command hook#49776
fix(ci): install mage via asdf if missing in pre-command hook#49776orestisfl wants to merge 1 commit intoelastic:mainfrom
Conversation
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.
|
This pull request doesn't have a |
🤖 GitHub commentsJust comment with:
|
📝 WalkthroughWalkthroughA pre-command hook step was added to ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
.buildkite/hooks/pre-command
| # 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 | ||
|
|
There was a problem hiding this comment.
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.
|
Closing to handle on the image instead |
Proposed commit message
This PR adds a guard in
.buildkite/hooks/pre-commandtoasdf install magethe required version if missing.Checklist
I have commented my code, particularly in hard-to-understand areasI have made corresponding changes to the documentationI have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature works.I have added an entry in./changelog/fragmentsRelated issues