Conditional Commands?

Is there a way to create a command and then in your step block, add a when: on_fail? I can’t find a way that passes the config validator.

Use case: we have a custom slack notifier that can DM people via the Github username, and I want to notify build success / failure directly to the individuals, but I can’t get a reusable command to work for that.

Hi Josh! Let me move this to our orbs category for those folks to see and help with :slight_smile:

@jimbojsb when: on_fail is for steps, not commands, remember:

(A command can consist of many steps, so command ≠ step, necessarily.) So, in order to create that for your command, you will need simply add it to every step that is part of your command.

If you’re having issues, you might try dropping your orb.yml or config.yml here so folks can take a look.

1 Like

What I was trying to do was have a command that does a custom internal notification, and that command takes a recipient and message argument. So when I use that command as a step, I wanted to have that step be on_fail. Unless I’m misunderstanding how to use commands entirely.

If you share the config.yml for the command it may help, but you can put the when: on the steps of the command as Rose said. Then the command will always run, but none of the steps that make it up will. That felt like very awkward English, but maybe it helped?