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}'
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
What is the solution for those that utilize a self-hosted local runner (that does not support pipes)?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.