Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Send notification if build failure log contains specific error message or code


I have a Bitbucket pipeline which internally calls different APIs for authentication and other functionalities. I want to get notification for all the pipeline failures. But if the failure log contains specific error message or error code, I would like send a notification to other teams as well. These team may change base based on the error code/message.

Is there a way to achieve this scenario in Bitbucket pipeline.

2 answers

Hi @Devendra Sharma 

Good question!

Also, you can use $BITBUCKET_EXIT_CODE variable in the after-script section.

$BITBUCKET_EXIT_CODE - the exit code of a step, if step success value setup to 0

with pipes for notification, alerting, monitoring


- <some build logic>
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: atlassian/datadog-send-event:1.1.2

or atlassian/email-notify

build: &build
name: Build
- echo "Starting build..."
#- <your build logic>
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: atlassian/email-notify:0.3.12
FROM: ''
TO: ','
HOST: ''
SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}'


To discover more pipes, visit Bitbucket Pipes Marketplace.


Best regards,
Oleksandr Kyrdan

0 votes
Syahrul Atlassian Team Jan 03, 2022

Hi @Devendra Sharma


Currently, we don't have the feature to create a custom email notification for specific error messages in Bitbucket pipeline build logs.


We only sent email notification for failed build at this moment, but I have proceeded to raise a feature request on behalf of you, please Vote and Watch  the feature request so that you'll receive an update whenever we have any at:

I hope this helps.


@Syahrul Hello Folks, Is this issue fixed?

What I'm looking for in the pipeline? I'm running a set of Terraform commands in the bit bucket pipeline, Which will kick off commands one after another: 


Terraform init

Terraform validate

Terraform plan

  1. Plan success-> send an email to a list of users->
  2. Wait for approval that has been created Via..,  "Jira service management"
  3. maybe a Day/2 and <Once approved, the pipeline has to kick the tf apply command.
  4. Once the approved button is hit, Pipeline should have to run the "terraform apply".

Which i followed link on internet: 

1. @o_kyrdan Is this worked?

2. @Syahrul  Will this works?

       i. bitbucket-and-jira-service-management

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events