helmfile "hook ... command ... failed" in CI
helmfile ran a hooks: command (for example a presync or postsync step) and it exited non-zero. helmfile stops the operation and prints the hook event and the failing command.
What this error means
helmfile apply fails with "hook[...]: command \"...\" ... exited with non-zero status" naming the release, the hook event, and the command that failed.
hook[presync]: warn while executing hook "./scripts/migrate.sh"
command "./scripts/migrate.sh" exited with non-zero status:
EXIT STATUS: 1Common causes
The hook command itself failed
The script or binary the hook runs returned non-zero because of a real error inside it, and helmfile surfaces that.
The hook command is missing or not executable
The command is not on PATH, not marked executable, or its working directory in CI differs from local, so it fails to run.
How to fix it
Read the hook output and fix the command
- Identify which hook event and command failed from the message.
- Reproduce the command locally with the same working directory.
- Fix the underlying error, or ensure the script is present and executable in CI.
chmod +x scripts/migrate.sh
./scripts/migrate.sh # reproduce the failure locallyDeclare the hook with an explicit command and args
Use the structured hook form so the command and its arguments are unambiguous in CI.
releases:
- name: api
chart: ./charts/api
hooks:
- events: ["presync"]
command: "./scripts/migrate.sh"
args: ["--env", "prod"]How to prevent it
- Keep hook scripts executable and committed to the repo.
- Use paths relative to the helmfile so working directory does not matter.
- Test hook commands in isolation before wiring them into a release.