Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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

Hi,

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

atlassian/datadog-send-event

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

or atlassian/email-notify

build: &build
step:
name: Build
script:
- echo "Starting build..."
#- <your build logic>
after-script:
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: atlassian/email-notify:0.3.12
variables:
USERNAME: 'myemail@example.com'
PASSWORD: $PASSWORD
FROM: 'myemail@example.com'
TO: 'example1@example.com, example2@example.com'
HOST: 'smtp.gmail.com'
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
Atlassian Team members are employees working across the company in a wide variety of roles.
Jan 03, 2022

Hi @Devendra Sharma

G'Day!

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.

Cheers,
Syahrul

@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? 
https://community.atlassian.com/t5/Bitbucket-questions/Send-notification-if-build-failure-log-contains-specific-error/qaq-p/1878124

2. @Syahrul  Will this works?
https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-Pipelines-amp-approvals/qaq-p/1659160

       i. https://bitbucket.org/blog/a-modern-approach-to-change-management-with- bitbucket-and-jira-service-management

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events