You can easily integrate Azure DevOps pipelines with any Slack Channel and get notifications of any pipeline related activity in Azure DevOps directly in that slack channel. You can subscribe for builds, releases, YAML pipelines, Approve pipeline stages from slack. In this blog post, we will see how to configure Azure DevOps Pipeline integration with a Slack channel. If you also want to get notified for any Azure DevOps Repos related changes in your slack channel then you can read below blog post:
Integrate Azure Devops Repos with a Slack Channel
How to Install Azure Pipelines app to Slack Workspace
First, you need to add Azure Pipelines Slack app and install this app to your Slack workspace.
There is another way to add this app to your slack workspace by searching for Azure Pipelines app from Slack by clicking on Apps link on left hand side and Click on Add. As the app is already installed in my case, therefore Add button is not showing. If you do not have this app installed in your slack workspace, it will show an Add button.
You will be redirected to a page where Azure Pipelines app will request permissions to your Slack Workspace. You can click on Review Permissions tab to go through the permissions. If you have approval control for installation of apps to your slack workspace, then you can Add a message in the message box and click on Submit to send the request to slack manager.
Once the Request is submitted, you can see the status on the button will change from Add to Slack to Request submitted. You can ask your slack manager to approve the installation of Azure Pipelines.
After Slack Manager approves the request, you should see below message from slack manager to your slack workspace confirming that Azure Pipelines application installation.
How to Subscribe to Azure Pipelines notifications for any Slack Channel
If you are setting up notifications to your Private Slack Channel then you need to invite the bot to your private channel first by using /invite @azurepipelines command. For public Slack channels, you can skip this step and directly use /azpipelines signin command.
After you invite Azure pipeline to the slack channel, you will get a message confirming that azurepipelines has been added to <channel name> by <name of the user who invited azurepipelines>.
In the chatbox of the slack channel (where you want to receive notifications). Type a command /azpipelines signin and press Enter.
You should now get a Sign in button and Enter code button. Click on Sign in to proceed. Once you successfully authenticate using your administrator account, you will get a code which you can enter by clicking on Enter code button to complete the sign in process.
|If you click on Enter code button and you do not get a pop-up box for entering a code then there could be issues with the Installation of Azure pipeline app in your slack workspace. You can remove Azure pipelines app from slack and reinstall it again. Try to signin and Enter code after reinstallation of this app.|
Now after you successfully signed in, Use the command /azpipelines subscribe [project url] or /azpipelines subscribe [pipeline url]. Press press Enter after typing this command in chat box of the slack channel. It may take few seconds to get a confirmation message.
By default, you will be automatically subscribed to below notifications:
- Run state changed
- Run stage waiting for approval
- Deployment started
- Deployment completed
- Deployment approval pending
How to verify Azure DevOps Pipelines subscription to slack channel
First and easier way is to verify the subscription is by using a command /azpipelines subscriptions. This will list your subscriptions for a Slack channel. Go to the channel which has been subscribed to the notifications and in the chat box enter this command.
Second option is to verify the subscriptions using Service Hooks under Project Settings from Azure DevOps portal. Below are the steps for checking configured notifications from Azure DevOps Service hooks:
- Login on Azure DevOps Portal Organization. For example: https://dev.azure.com/<your org name>
- Click on the Project which you integrated with Slack Channel.
- Click on Project settings.
- Click on Service hooks.
Below default notifications will be configured when you will subscribe to the Azure DevOps Project URL from a slack channel.
If you try to edit any of the subscribed notifications from Service hooks, you will get an ALERT message “This subscription is being managed by the consumer service. To modify settings for this subscription. Visit Workpace Message Apps.” Which means that this subscription notification is being managed by Slack and to Unsubscribe from this notification you will need to go to that slack channel and use a command /azpipelines unsubscribe all [project url] or /azpipelines subscriptions command.
How to Subscribe to Azure Pipelines notifications for specific Pipeline
You may not want notifications from all Pipeline to a particular slack channel. Its possible to get notifications from just one pipeline using below steps:
- Go to Azure DevOps -> Pipelines and then Under pipelines on Pipelines again.
- You will be able to see three tabs on the top of the page “Recent”, “All” and “Runs”.
- Find your pipeline in any of the tabs and click on it.
- Now, Copy the URL of this Pipeline from Address bar of the browser.
- Go to Slack channel and type
/azpipelines subscribe <pipeline URL>
When you specify the URL of a specific pipeline to /azpipelines subscribe command, it will only configure notifications from that pipeline instead of any pipeline.
We have now seen how to configure Azure DevOps pipelines integrations to any slack channel. When you are working in a team this makes the job really easy as everything in the team will know on the activities related to Azure pipelines. If there are any Pipeline stage requires approval then you get an option to Approve or Reject that request. Also if there are any failures then anyone from the team can simply click on the Error link notification in that slack channel and land directly on the relevant page. This blog post covers configuration of Azure Pipelines with Slack Integration. You can also configure the integration of Azure Repos with any Slack channel.