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

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
4,463,739
Community Members
 
Community Events
176
Community Groups

i want to send email to developer after the deployment, it may be successful or failed how can do it

Edited

i have written a yml for that just configured ec2 details after that i need to send an email to developers that depolyment is done with the status failed r sucess.

image: atlassian/default-image:3

pipelines:
default:
- parallel:
- step:
name: 'Build and Test'
script:
- echo "Your build and test goes here.."
- step:
name: 'Lint'
script:
- echo "Your linting goes here..."
- step:
name: 'Security scan'
script:
- echo "Your security scan goes here..."

# The following deployment steps will be executed for each pipeline run. To configure your steps and conditionally deploy see https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/
- step:
name: 'Deployment to Staging'
deployment: staging
script:
- pipe: atlassian/ssh-run:0.4.0
variables :
SSH_USER: '******'
SERVER: '*************'
COMMAND: 'mkdir test21'
- step :
name: 'email notifications'
script:
- ALERT_TYPE="success"
- if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
- pipe: 'atlassian/email-notify:0.5.0'
variables :
USERNAME: '$SOME_USERNAME'
PASSWORD: $PASSWORD
FROM: 'noreply@atlassian.com'
TO: '$SOME_EMAIL_TO'
HOST: 'smtp.gmail.com'
PORT: '25'
SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}'

 

1 answer

0 votes
Mark C Atlassian Team Feb 13, 2022

Hi @amol funde

Welcome to the community.

For you to be able to run scripts on Pipelines regardless if the build is failed or successful, you can use the configuration called "after-script".
After-script will allow you to run commands at the end of a step execution.

For your current YAML configuration, you'll just need to add the step "email notifications" as an after-script of the step "Deployment to Staging".

Your "Deployment to Staging" step, should look like below:

      - step:
          name: 'Deployment to Staging'
          deployment: staging
          script:
            - pipe: atlassian/ssh-run:0.4.0
              variables :
                SSH_USER: '******'
                SERVER: '*************'
                COMMAND: 'mkdir test21'
          after-script:
            - ALERT_TYPE="success"
            - if [[ $BITBUCKET_EXIT_CODE -ne 0 ]]; then ALERT_TYPE="error" ; fi
            - pipe: 'atlassian/email-notify:0.5.0'
              variables :
                USERNAME: '$SOME_USERNAME'
                PASSWORD: $PASSWORD
                FROM: '$SOME_EMAIL_FROM'
                TO: '$SOME_EMAIL_TO'
                HOST: 'smtp.gmail.com'
                PORT: '25'
                SUBJECT: '${ALERT_TYPE}:Bitbucket Pipe Notification for ${BITBUCKET_BRANCH}'

Hope it helps and let me know how it goes.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events