Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to run pipe conditionally in `after-script`?

전지원 April 14, 2023

Hi, I want to run pipe `slack-notify` conditionally after a step finished (in after-script statement).


Is there any syntax that run the pipe conditionally by checking BITBUCKET_EXIT_CODE (only when FAILED(1)) ?


Desired situation using pseudo-YAML:


  - envsubst < ".pipelines/failed_pipe_payload.json.template" > ".pipelines/slack_payload.json"
  - pipe: atlassian/slack-notify:2.0.0
       PAYLOAD_FILE: .pipelines/slack_payload.json
        variables.BITBUCKET_EXIT_CODE: 1

1 answer

1 accepted

1 vote
Answer accepted
Oleksandr Kyrdan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 14, 2023

Hi @전지원 

Thank you for your question!

You could try the next solution:

- ...
- if [[ BITBUCKET_EXIT_CODE -eq 0 ]]; then exit 0; else echo "Step failed"; fi
envsubst < ".pipelines/failed_pipe_payload.json.template" > ".pipelines/slack_payload.json"
- pipe: atlassian/slack-notify:2.0.0


Best regards,
Oleksandr Kyrdan

전지원 April 16, 2023

It works! Thanks for your support :)

I think it would be good if condition syntax is supported for pipe too!

Like # people like this
Bitwise DEVS February 27, 2024

Hi, I want to verify if `$` is really no longer needed in

`BITBUCKET_EXIT_CODE` since if I remember correctly it is always prepend to the variable name in order to use it?


Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events