Ability to conditionally skip pipeleine steps based on the results of previous steps

I need to implement the fillowing for my CI pipeline:

pipeline:
  deploy:
    image: 'my-deploy-image'
    commands:
      # Skip unsupported targets
      - target-supported || { echo abort-deployment; exit 123 }
      # Do deployment
      - deploy
    when:
      event: deployment

  # Only when deployed
  slack-on-success:
    image: plugins/slack
    when:
      event: deployment
      status: [ success ]

  # Only when deploy failed, but not when deplyment skipped due to target is unsupported
  slack-on-failure:
    image: plugins/slack
    when:
      event: deployment
      status: [ failure ]

This is simplified example, but the idea should be clear. I want to sned slack notification when build succeeded or failed, but not when it’s aborted. Seems like I need some kind of extra status besides success and failure. How could I implement it?

2 Likes