Job 'notify' has 'needs: [deploy]' and should run even when 'deploy' fails, but only when the failure was a real failure (not a skip). Which job-level 'if' condition is most appropriate?
Select an answer to reveal the explanation.
Short Explanation and Infographic
always() keeps the job eligible when an upstream failed; combine it with needs.deploy.result == 'failure' to exclude skipped or cancelled deploy outcomes.
Full explanation below image
Full Explanation
By default a job is skipped when a needed job fails. Using 'if: always()' (or 'if: failure()' carefully) re-enables evaluation after upstream failure. For a failure-only notify path, pair always() with an explicit check of needs.<job>.result. The result values include success, failure, cancelled, and skipped. failure() alone refers to the status of prior steps/jobs in a way that is easy to misread at job level when multiple needs exist. Checking only != success would also fire on cancelled or skipped. cancelled() targets cancellation, not failure. Prefer explicit needs.*.result comparisons for multi-job graphs.