In CircleCI, I know it's possible to run a step only if the job that contains it has failed, but can the same thing be done with jobs (without adding an extra failure handling step to every job)?
Specifically, I'm trying to send a slack notification if any job (e.g. checkout) in a workflow fails.
I can't see a simple way to do that; at the job level there's no equivalent to the step-level
when: on_failattribute.All I can suggest is to use Dynamic Config. Your "Setup Workflow" would include the main jobs you want to check the outcome of, plus a "waiter" job that:
Failedstatus.Failed, the "waiter" job sets a parameter totrue(for example,{ "extra-job": true }that you pass to thecontinuecommand of thecircleci/continuationorb (via the command'sparametersparameter), along with the "continuation"config.yml(which will only include the job that sends a slack notification).You can find an example of a "waiter" job in this CircleCI Discuss post. It doesn't include the part where you check for
Failedstatuses and sets the JSON object that'll be later used as a parameter; you'll need to add that.In the "continuation" config:
You'll need to declare a boolean pipeline parameter
extra-jobwith a default value offalseThe execution of the one workflow that has the "Slack job" will be conditioned on the
extra-jobpipeline parameter beingtrue:I hope this helps.