Skip to content
Latchkey

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.

helmfile
hook[presync]: warn while executing hook "./scripts/migrate.sh"
command "./scripts/migrate.sh" exited with non-zero status:
EXIT STATUS: 1

Common 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

  1. Identify which hook event and command failed from the message.
  2. Reproduce the command locally with the same working directory.
  3. Fix the underlying error, or ensure the script is present and executable in CI.
Terminal
chmod +x scripts/migrate.sh
./scripts/migrate.sh   # reproduce the failure locally

Declare the hook with an explicit command and args

Use the structured hook form so the command and its arguments are unambiguous in CI.

helmfile.yaml
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.

Frequently asked questions

What causes ""hook ... failed""?
The script or binary the hook runs returned non-zero because of a real error inside it, and helmfile surfaces that.
How do I fix "hook ... failed"?
Read the hook output and fix the command

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card