Slack alert on failing (external) orb

Hi everyone! :wave:

For my project, I need to trigger a slack alert when deploy fails.
Sadly, documentation only shows how we can trigger a slack alert from a custom deploy job.

In my case, I use an external orb for deploy and I can’t (for sure?) add a step to it.

So, what can I do ? Can I run a job (that use slack orb) that depend on the deploy one even if it fails ? Can I extends orb steps ?

Here some code to “describe” my situation:

version: 2.1

orbs:
  global: anexternalorb/global@1.1.11

jobs:
  test_container:
    ...etc

workflows:
  version: 2
  test_and_deploy:
    jobs:
      - test_container:
          name: Test in Container
          ...etc
      - global/deploy_to_kubernetes:
          name: Deploy Kubernetes sandbox
          ...etc

Thanks by advance :slight_smile:

:wave: Hi @jdemangeon! And welcome to the CircleCI community!

I believe this is a good use-case for the post-steps functionality.

Your post-steps command would need to leverage the Slack orb and the when attribute.

Let me know if this helps.

Hi @yannCI! :slight_smile:

Thanks a lot, it works with the following code:

version: 2.1

orbs:
  global: anexternalorb/global@1.1.11
  slack: circleci/slack@4.6.2

jobs:
  test_container:
    ...etc

workflows:
  version: 2
  test_and_deploy:
    jobs:
      - test_container:
          name: Test in Container
          ...etc
      - global/deploy_to_kubernetes:
          name: Deploy Kubernetes sandbox
          post-steps:
              - slack/notify:
                  event: fail
                  template: basic_fail_1
          ...etc

Not related, can I apply a branch filter on this post-step?

To explain, I want to apply this post-step to all previous jobs before deploy (eg: Test in Container) and I don’t see a way to do it in simple way. So, I want to create an alias with a filter on the post-step and apply this alias to all previous (required) steps

Anyone known if it’s possible ? :thinking: :pray: