Reputation: 211
I'd like to send Slack notifications to a channel when a deployment starts. The current available notifications are for deployment success, failure or stopped but nothing for the start of a deployment.
Is there a workaround to get the notification when the deployment begins?
Thanks.
Upvotes: 4
Views: 915
Reputation: 1265
If you happen to use git tags (or are willing to move to using tags), e.g. 1.2.3
you can be notified that a tag is pushed and ensure your trigger is initiated by those tags. Then, you can receive a notification once the deployment has completed as well, for a total of 2 separate notifications. This won't work for every situation but it can at least notify you of a production level deployment that is about to be initiated (which is how I use it).
To do this:
Repository-wide
(or a branch, if you prefer) select tag created
deployment succeeded
and deployment failed
notifications are still selected.Then, in your pipelines update it to this:
pipelines:
tags:
# Matches tags like '1.2.3'
'*.*.*':
# ... your tag-specific pipeline steps and etc...
Upvotes: 0
Reputation: 3834
You can just use Atlassian's Slack notification pipe https://bitbucket.org/product/features/pipelines/integrations?p=atlassian/slack-notify
definitions:
yaml-anchors:
- &slack-notify-variables
WEBHOOK_URL: $SLACK_WEBHOOK
# ...
- &deploy-step
script:
- pipe: atlassian/slack-notify:2.0.0
variables:
<<: *slack-notify-variables
MESSAGE: "Deployment to $BITBUCKET_DEPLOYMENT_ENVIRONMENT started"
- bash deploy.sh $BITBUCKET_DEPLOYMENT_ENVIRONMENT
pipelines:
branches:
main:
- step:
<<: *deploy-step
deployment: my-staging-environment
- step:
<<: *deploy-step
deployment: my-production-environment
Upvotes: 0