Skip to content

Skip PostDeploy convention when the main script fails

Summary

  • A non-zero main-script exit does not throw, so the Calamari pipeline carried on and ran the PostDeploy convention against a failed deploy. PostDeploy hosts smoke tests, cache warm-up, and service-mesh registration — running them on an already-failed deploy is worse than skipping them.
  • Add a single-source RunScriptCommandContext.DeployHasFailed predicate (an upstream step threw or the main script exited non-zero) and gate PostDeploy on it via an opt-in skipWhenDeployFailed flag on ConventionScriptStep. PostDeploy passes true; PreDeploy keeps the default false (it runs before the main script, so the failure state is never set when it is evaluated).
  • DeployFailedConventionStep now consults the same DeployHasFailed predicate, so the skip-PostDeploy gate and the run-DeployFailed gate can never disagree about whether the deploy failed (previously the predicate was duplicated inline).
  • Non-breaking: skipWhenDeployFailed is an optional constructor parameter, so every existing call site / test is unchanged. Only PostDeploy's behaviour on a failed main script changes. The separate IIS DeployToIISWebSite.ps1 convention system already skips PostDeploy on failure and is untouched.

Test plan

  • E2E (real bash, RunScriptCommandTests): main exit 3 + PostDeploy.sh + DeployFailed.sh present → PostDeploy sentinel absent (skipped), DeployFailed sentinel present (ran), ExitCode == 3
  • E2E (real bash): main exit 0 → PostDeploy runs, DeployFailed skipped (happy-path regression guard)
  • Unit (ConventionScriptStepTests): IsEnabled gating — flag+non-zero-exit → skip; flag+ExecutionFailed → skip; flag+exit-0 → run; default-flag ignores failure state (PreDeploy unaffected)
  • Unit: DeployHasFailed predicate [Theory] over (executionFailed × exitCode) branches
  • Regression: full Squid.Calamari.Tests suite 556/556 green; dotnet build Squid.sln 0 errors

Merge request reports

Loading