GoogleContainerTools/skaffold · error

running builder post-hooks: %w

Error message

running builder post-hooks: %w

What it means

pipelineBuilderWithHooks.PostBuild runs the underlying builder's PostBuild, then executes build post-hooks. If any post-hook command fails, it is wrapped as "running builder post-hooks: %w". Post-hooks run after all builds are complete, so this signals teardown/cleanup hook failure.

Source

Thrown at pkg/skaffold/runner/builder.go:107

		return err
	}

	if err := b.hooksRunner.RunPreHooks(ctx, out); err != nil {
		return fmt.Errorf("running builder pre-hooks: %w", err)
	}

	return nil
}

// PostBuild executes any one-time teardown required after all builds on this builder are complete,
// followed by any Build post-hooks set for the pipeline.
func (b *pipelineBuilderWithHooks) PostBuild(ctx context.Context, out io.Writer) error {
	if err := b.PipelineBuilder.PostBuild(ctx, out); err != nil {
		return err
	}

	if err := b.hooksRunner.RunPostHooks(ctx, out); err != nil {
		return fmt.Errorf("running builder post-hooks: %w", err)
	}

	return nil
}

func withPipelineBuildHooks(pb build.PipelineBuilder, buildHooks latest.BuildHooks) build.PipelineBuilder {
	return &pipelineBuilderWithHooks{
		PipelineBuilder: pb,
		hooksRunner:     hooks.BuildRunner(buildHooks, hooks.BuildEnvOpts{}),
	}
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Inspect the wrapped error and run the failing post-hook command manually to reproduce
  2. Fix the post-hook command/script in skaffold.yaml (paths, permissions, credentials)
  3. If the hook is best-effort cleanup, make the script tolerant (e.g. `|| true` / explicit exit 0) so builds aren't blocked

Example fix

// before (skaffold.yaml)
build:
  postHooks:
    - exec: ["bash", "./scripts/cleanup.sh"]  # fails when artifacts absent
// after (cleanup.sh)
rm -rf ./.cache || true
exit 0
Defensive patterns

Strategy: try-catch

Validate before calling

// verify post-hook script tolerates missing artifacts
sh("./scripts/cleanup.sh || echo 'post-hook would fail'")

Try / catch

try {
  await run('skaffold build')
} catch (err) {
  if (/running builder post-hooks/.test(err.message)) {
    console.error('post-hook failed (build itself succeeded):', err.cause ?? err.message)
  }
  throw err
}

Prevention

When it happens

Trigger: A `build.postHooks` command configured in skaffold.yaml exits non-zero after artifact builds finish.

Common situations: Cleanup or artifact-push scripts failing because a registry is unreachable, credentials are missing, or the cleanup command assumes files that were not produced.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/68682fd2796f733a. Report an issue: GitHub.