Always Run steps

Is there a way to designate a step as one that should “always run”? I would like to have a step at the end of the pipeline run whether the overall process is successful or not.

Hello!

Could I ask what is your exact scenario in order to understand your question better? Most times it is much better to do the opposite thing , i.e. put the fail_fast property in steps that you don’t want to affect the workflow (even if they fail)

I want to send a Slack notification regarding the build outcome using the “cloudposse/slack-notifier” plugin. I tried the generic Slack integration, but the problem is that I want to specify different channels for different projects and the generic Slack notifier is only configurable for a single channel across all projects.
When the build fails, the notification does not go out because the pipeline does not reach that step.

This is what we used instead (and it refers to a prior step called installHelmChartForPROD ):

  sendSlackSuccessForPROD:
    stage: pushToPROD
    type: slack-message-sender
    arguments:
      WEBHOOK_URL: 'https://hooks.slack.com/services/<insert your channel here>'
      MESSAGE: '${{CF_BUILD_INITIATOR}} triggered a build to be deployed to PROD. Version is ${{CHART_VERSION}}-build-${{BUILD_NUMBER}}. Deploy successful.'
    when:
      condition:
        all:
          installPassed: "steps.installHelmChartForPROD.result == 'success'"
  sendSlackFailForPROD:
    stage: pushToPROD
    type: slack-message-sender
    arguments:
      WEBHOOK_URL: 'https://hooks.slack.com/services/<insert your channel here>'
      MESSAGE: '${{CF_BUILD_INITIATOR}} triggered a build to be deployed to PROD. Version is ${{CHART_VERSION}}-build-${{BUILD_NUMBER}}. Deploy failed!'
    when:
      condition:
        all:
          installFailed: "steps.installHelmChartForPROD.result != 'success'"
2 Likes

Thanks! Do you know of any way to access the status of the build as a whole? Otherwise, is it possible to have multiple steps be a part of the condition statement?

It is possible to have

  1. Multiple conditional checks
  2. Run multiple steps as a reaction to a conditional check

For the latter, it is easier to have the entire pipeline be parallel so as to code the conditional steps but it does make it rather messy to follow or map in the stage view.

Hence why I still prefer to use sequential.

1 Like

@davidhubbell you can access the result of the whole pipeline as workflow.result

But this only works in full parallel pipelines: