Breyta

Deila með


Use Azure Pipelines with Slack

Azure DevOps Services

This article shows you how to use the Azure Pipelines app for Slack to monitor your pipeline events. You can establish and manage subscriptions for pipeline events like builds, releases, and pending approvals. Notifications for these events are delivered directly to your Slack channels.

Note

This feature is only available on Azure DevOps Services. Typically, new features are introduced in the cloud service first, and then made available on-premises in the next major version or update of Azure DevOps Server. For more information, see Azure DevOps Feature Timeline.

Prerequisites

  • A Slack account with permission to install an app to your Slack workspace.
  • An Azure DevOps project with Project Collection Administrators or Project Administrators permissions.

Install the Azure Pipelines app

Install the Azure Pipelines Slack app to your Slack workspace. Once the app installs, you see the following welcome message. Enter /azpipelines to start interacting with the app.

A screenshot showing the Azure Pipelines app welcome message.

Connect to your pipeline

Once the app is installed in your Slack workspace, you can connect the app to any pipeline you want to monitor. You must authenticate to Azure Pipelines before running any commands.

A screenshot showing the sign-in prompt message.

Subscribe to pipelines

To start monitoring all pipelines in a project, enter /azpipelines subscribe <project url> in a channel, replacing <project url> with your Azure DevOps project URL. The project URL can link to any page within your project except pipeline pages, for example /azpipelines subscribe https://dev.azure.com/myorg/myproject/.

You can monitor a specific pipeline by using /azpipelines subscribe <pipeline url>. The pipeline URL can link to any page within your pipeline that has a definitionId or a buildId/releaseId in the URL. For example:

  • /azpipelines subscribe https://dev.azure.com/myorg/myproject/_build?definitionId=123
  • /azpipelines subscribe https://dev.azure.com/myorg/myproject/_release?definitionId=123&view=mine&_a=releases

The subscribe command subscribes you to the following notifications by default:

  • For YAML pipelines:
    • Run stage state changed
    • Run stage waiting for approval
  • For Classic build pipelines, Builds completed
  • For Classic release pipelines:
    • Release deployment started
    • Release deployment completed
    • Release deployment approval pending

A screenshot showing notification example.

Manage subscriptions

To manage the subscriptions for a channel, enter /azpipelines subscriptions. This command lists all the current subscriptions for the channel and lets you add or remove subscriptions.

A screenshot showing a list of subscriptions.

Note

Team Administrators can't remove or modify subscriptions created by Project Administrators.

Customize subscriptions

The default subscriptions don't have any filters applied, but you can customize these subscriptions according to your preferences. For instance, you might want to receive notifications only for failed builds or deployments to production. You can apply filters to customize which messages you receive in your channel.

To customize a subscription:

  1. Run the /azpipelines subscriptions command to list all your subscriptions.
  2. Select Add subscription.
  3. Select the event you want to subscribe to, and then select your desired configuration.
  4. Select Save.

For example, to get notifications only for failed builds, select Failed under Build status.

A screenshot showing how to customize a subscription.

Approve deployments

You can approve deployments from within your Slack channel without going to Azure Pipelines. Subscribe to the Run stage waiting for approval notifications for YAML pipelines or the Release deployment approval pending notifications for Classic releases. Both of these subscriptions are created by default when you subscribe to a pipeline.

A screenshot showing pipeline approval in Slack.

The Azure Pipelines app for Slack lets you handle all the checks and approval scenarios that are available in the Azure Pipelines portal. These scenarios include single approver, multiple approvers, and team-based approval. You can approve requests either individually or on behalf of a team.

A screenshot showing a predeployment pipeline approved in Slack.

Remove all subscriptions

To declutter your channel, you can use the /azpipelines unsubscribe all <project url> command to unsubscribe from all pipelines in a project. For example, /azpipelines unsubscribe all https://dev.azure.com/myorg/myproject.

Important

Only Project Administrators can run this command.

Command reference

The Azure Pipelines app for Slack supports the following commands:

Command Description
/azpipelines subscribe <pipeline url or project url> Subscribe to a pipeline or all pipelines in a project and receive notifications.
/azpipelines subscriptions Add or remove subscriptions for this channel.
/azpipelines feedback Report a problem or suggest a feature.
/azpipelines help Get help on the commands.
/azpipelines signin Sign in to your Azure Pipelines account.
/azpipelines signout Sign out of your Azure Pipelines account.
/azpipelines unsubscribe all <project url> Remove all project pipelines and their associated subscriptions from a channel.

Notifications in private channels

The Azure Pipelines app can also help you monitor pipelines activity in your private channels. You need to invite the bot to your private channel by using /invite @azpipelines. Once you add the bot, you can configure and control your notifications the same way as for a public channel.

Conditions and limitations

  • You can use the Azure Pipelines app for Slack only with Azure DevOps Services.
  • To set up the subscriptions, you must be an admin of the project containing the pipeline.
  • Notifications aren't supported inside direct messages.
  • Deployment approvals that have the Revalidate identity of approver before completing the approval policy applied aren't supported.
  • To use the app, Third party application access via OAuth must be enabled in Azure DevOps Organization settings > Security > Policies.

Troubleshooting

If you get the following errors when using the Azure Pipelines App for Slack, try the procedures in this section.

Sorry, something went wrong. Please try again.

The Azure Pipelines app uses the OAuth authentication protocol, and requires Third-party application access via OAuth to be enabled. To enable this setting, navigate to Organization Settings > Security > Policies, and enable Third-party application access via OAuth.

A screenshot showing how to enable third party access via OAuth.

Configuration failed. Please make sure that the organization exists and that you have sufficient permissions.

  1. Sign out of Azure DevOps by navigating to https://aka.ms/VsSignout.

  2. In a private/incognito browser window, navigate to https://aex.dev.azure.com/me and sign in. Make sure to select the directory containing the organization that has your pipeline.

    A screenshot showing how to select your pipeline directory.

  3. In the same browser, open a new tab and go to https://slack.com. Sign in to your workspace using the web client, and then run /azpipelines signout followed by /azpipelines signin.

  4. Select the Sign in button. If you're redirected to a consent page, verify that the directory displayed next to your email address matches the one you signed in to.