Azure Repos with Slack
Azure DevOps Services
If you use Slack, you can use the Azure Repos app for Slack to easily monitor your Azure Repos repositories. Set up and manage subscriptions to receive notifications in your channel whenever code is pushed or checked in and whenever a pull request (PR) gets created, updated, or merged. This app supports both Git and Team Foundation Version Control (TFVC) events.
Prerequisites
- To create subscriptions in a Slack channel for repository-related events, you must be a member of the Project Administrators group, or be a team administrator. To get added, see Change project-level permissions or Add a team administrator.
- To receive notifications, the Third-party application access via OAuth setting must be enabled for the organization. For more information, see Change application access policies for your organization.
Note
- You can only link the Azure Repos app for Slack to a project hosted on Azure DevOps Services at this time.
- Notifications are currently not supported inside direct messages.
Add the Azure Repos app to your Slack workspace
Go to the Azure Repos Slack app and select Add to Slack.
Once added, you receive something like the following welcome message.
Use the
/azrepos
Slack handle to interact with the app. A full list of commands is provided in the Command reference section of this article.
Connect the Azure Repos app to your repositories
Connect and authenticate yourself to Azure Repos using
/azrepos signin
command.Select Sign in.
Accept the Azure Repos Slack Integration.
A verification code displays for use in your chat app to complete authentication.
Copy the authentication code.
Select Enter code, paste the code, and then select Submit.
Confirmation of sign-in displays within the chat.
To start monitoring all Git repositories in a project, use the following slash command inside a channel:
/azrepos subscribe [project url]
The project URL can be to any page within your project (except URLs to repositories). For example:
/azrepos subscribe https://dev.azure.com/myorg/myproject/
You can also monitor a specific repository using the following command:
/azrepos subscribe [repository url]
The repository URL can be to any page within your repository that has your repository name. For example, for Git repositories, use:
/azrepos subscribe https://dev.azure.com/myorg/myproject/_git/myrepository
For TFVC repositories, use:
/azrepos subscribe https://dev.azure.com/myorg/myproject/_versionControl
Note
You can only subscribe to public repositories.
The subscribe command gets you started with a default subscription. For Git repositories, the channel is subscribed to the Pull request created event (with target branch = main), and for TFVC repositories, the channel is subscribed to the Code checked in event.
Manage subscriptions
To view, add, or remove subscriptions for a channel, use the following subscriptions
command:
/azrepos subscriptions
This command lists all the current subscriptions for the channel and allows you to add new subscriptions or remove existing ones. When adding subscriptions, you can customize the notifications you get by using various filters, as described in the following section.
Note
Team administrators can't remove or modify subscriptions created by Project administrators.
Use filters to customize subscriptions
When a user subscribes to a repository using the /azrepos subscribe
command, a default subscription gets created. Often, users need to customize these subscriptions. For example, users might want to get notified only when PRs have a specific reviewer.
The following steps demonstrate how to customize subscriptions.
- Run the
/azrepos subscriptions
command. - In the list of subscriptions, if there's a subscription that is unwanted or must be modified (Example: creating noise in the channel), select the Remove button.
- Select the Add subscription button.
- Select the required repository and the desired event.
- Select the appropriate filters.
Example: Get notifications only when my team is in the reviewer list for a PR
Example: Tell me when merge attempts fail due to a policy violation
Note
- All the filters are typically drop-downs. But if the drop-down has greater than 100 items, then users must enter the values manually.
- For the TFVC Code Checked in event, the filter Under path must be of the format
$/myproject/path
.
Preview pull request URLs
When a user pastes the URL of a PR, a preview display like the following image, which helps to keep PR-related conversations contextual and accurate.
Once users sign in, this feature works for all channels in a workspace.
Remove subscriptions and repositories from a channel
Use the following command to clean up your channel by removing repositories and subscriptions.
/azrepos unsubscribe all [project url]
For example, the following command deletes all the subscriptions related to any repository in the project and removes the repositories from the channel. Only project admins can run this command.
/azrepos unsubscribe all https://dev.azure.com/myorg/myproject
Command reference
The following table lists all the /azrepos commands
you can use in your Slack channel.
Slash command | Functionality |
---|---|
/azrepos subscribe [repository url/ project url] | Subscribe to a repository or all repositories in a project for notifications |
/azrepos subscriptions | Add or remove subscriptions for this channel |
/azrepos signin | Sign in to your Azure Repos organization |
/azrepos signout | Sign out from your Azure Repos organization |
/azrepos feedback | Report a problem or suggest a feature |
/azrepos unsubscribe all [project url] | Remove all repositories (belonging to a project) and their associated subscriptions from a channel |
Notifications in private channels
The Azure Repos app can help you monitor the repository events in your private channels, too. Invite the bot to your private channel by using /invite @azrepos
. Then, you can manage your notifications the same way you would for a public channel.
Troubleshoot
If you're experiencing the following errors when using the Azure Repos App for Slack, follow the procedures in this section.
- Sorry, something went wrong. Please try again.
- Configuration failed. Please make sure that the organization '{organization name}' exists and that you have sufficient permissions.
Sorry, something went wrong. Please try again.
The Azure Repos app uses the OAuth authentication protocol, and requires Third-party application access via OAuth for the organization to be enabled. To enable this setting, navigate to Organization Settings > Security > Policies, and set the Third-party application access via OAuth for the organization setting to On.
Configuration failed. Please make sure that the organization '{organization name}' exists and that you have sufficient permissions.
Sign out of Azure DevOps by navigating to https://aka.ms/VsSignout
using your browser.
Open an In private or incognito browser window and navigate to https://aex.dev.azure.com/me
and sign in. In the dropdown under the profile
icon to the left, select the directory that contains the organization containing the repository to which you wish to subscribe.
In the same browser, start a new tab, navigate to https://slack.com
, and sign in to your work space (use web client). Run the /azrepos signout
command followed by the /azrepos signin
command.
Select the Sign in
button and you're redirected to a consent page like the one in the following example. Ensure that the directory shown beside the email is same as what was chosen in the previous step. Accept and complete the sign in process.
If these steps don't resolve your authentication issue, reach out to us at Developer Community.