Azure Pipelines Deployment Lifecycle Hook Invalid
Deployment strategies expose a fixed set of lifecycle hooks. runOnce supports preDeploy, deploy, routeTraffic, postRouteTraffic, and on.{success,failure}; using a hook the strategy does not define - or misspelling one - fails to compile.
What this error means
The pipeline rejects the deployment job with Unexpected value '<hook>' under the strategy, naming a hook that is not valid for that strategy. The deploy job never starts.
/azure-pipelines.yml (Line: 18, Col: 11): Unexpected value 'postDeploy'Common causes
Misspelled or non-existent hook
The hooks are exact keywords. postDeploy is not a hook (postRouteTraffic is); onFailure is not (on: { failure: ... } is). Anything outside the set is rejected.
Hook not offered by the strategy
canary adds no extra deploy phases beyond runOnce/rolling semantics - placing a hook a strategy does not define is invalid.
How to fix it
Use the exact hook names
Stick to the documented hooks and the on: block for success/failure.
strategy:
runOnce:
preDeploy:
steps: [ { script: echo prep } ]
deploy:
steps: [ { script: ./deploy.sh } ]
on:
failure:
steps: [ { script: ./rollback.sh } ]Check which hooks the strategy supports
- Confirm the strategy (
runOnce/rolling/canary) and its valid hooks in the deployment-jobs docs. - Replace any unsupported hook with the nearest valid one.
- Move success/failure handling into the
on:block, not a custom hook.
How to prevent it
- Keep a reference of the valid lifecycle hooks per strategy.
- Use
on: { success, failure }for post-deploy handling. - Validate the pipeline after editing deployment hooks.