Setting up actionable build notifications in Slack

CloudBees Core Personalized Slack Messaging sends Slack messages directly to you to notify you of relevant status information and build data at the end of the sequence, so that you know if the build was successful, and if not, the actions that need to be taken to get a failed build back on track. The notifications include information on build and test results, including direct links to results and error details.

Sending messages directly to Slack means that you do not need to switch between different tools to be alerted when builds complete, and in the case of failed builds you can take immediate action.

CloudBees Core Personalized Slack Messaging feature benefits

The CloudBees Core Personalized Slack Messaging feature provides the following benefits:

  • Provides feedback immediately upon completion of a build.

  • Highlights the causes of build failures quickly.

  • Limits context switching between tools.

  • Installs easily and does not require updates to Pipelines.

This feature does not require any modifications to Pipelines.

The process of setting up actionable build notifications in Slack requires an Administrator to complete the following steps from Slack’s App API:

And the following steps from the CloudBees Core Master:

Supported versions

The CloudBees Slack Integration plugin is available on the following versions and platforms:

  • CloudBees Core on modern cloud platforms version 2.222.4.3 (and higher)

  • CloudBees Core on traditional platforms version 2.222.4.3 (and higher)

Creating a new Slack App

The Slack App that Administrators create is a hub for messages that will be used by the CloudBees Slack Integration Plugin to notify users of information regarding builds: failures, JUnit errors, Pipeline Policy violations, or even when the build completes successfully.

For more information on creating a Slack Application see an introduction to Slack apps in the Slack API documentation.
To create a new Slack App for CloudBees Core Personalized Slack Messaging:
  1. Navigate to Slack’s App API in a browser.

  2. Select either Create an App if you have never created a Slack App before

    createApp

    or

    Create New App if you have previously created a Slack App.

  3. Enter an App Name.

  4. Select a Development Slack Workspace from the drop down menu.

    createSlackApp
  5. Select Create App.

  6. Select App Home in the left nav.

    appHome
  7. Select Review Scopes to Add.

  8. Scroll down to Scopes.

    scrollToScopes
  9. Select Add an OAuth Scope.

    addOAuthScope
  10. Select and add the following scopes:

    Table 1. Scopes
    Scope Description

    chat:write

    Send messages as <App Name>

    chat:write.customize

    Send messages as <App Name> with a customized username and avatar

    chat:write.public

    Send messages to channels <App Name> isn’t a member of

    files:read

    View files shared in channels and conversations that <App Name> has been added to

    files:write

    Upload, edit, and delete files as <App Name>

    links:read

    View some URLs in messages

    links:write

    Show previews of URLs in messages

    users:read

    View people in the workspace

    users:read.email

    View email addresses of people in the workspace

    You must include all of the scopes listed or the Slack App will not function properly. For example, without users:read and users:read.email, the plugin won’t be able to retrieve users.

Installing the new Slack App in a client workspace

Admin privileges are required in the Slack workspace to install the new Slack App.
To install the new Slack App in a client workspace:
  1. Sign in to your desired workspace.

  2. Select OAuth & Permissions in the left navigation.

    oauthAndPermissions
  3. Under OAuth Tokens & Redirect URLs select Install App to Workspace.

  4. Select Allow.

    allow
  5. Select Copy to copy the Bot User OAuth Access Token.

    copy

Installing the CloudBees Slack Integration Plugin

To install the CloudBees Slack Integration Plugin:

  1. From Operations Center or your CloudBees Core master, select Manage Jenkins > Manage Plugins.

  2. Select the Available tab.

  3. Use the Filter field to search for CloudBees Slack Integration Plugin.

  4. Select the checkbox to choose the CloudBees Slack Integration Plugin.

  5. Select Install without restart to install the plugin.

Adding the Slack Bot Token as secret text

Adding the Slack Bot token as a secret will allow it to be stored securely within the CloudBees Core master.

To add the Slack Bot Token as secret text:
  1. From your CloudBees Core Master, navigate to Manage Jenkins > Slack Integration.

    cb slack plugin
  2. Under Slack, to the right of Token, paste the token you copied when Installing the new Slack App in a client workspace.

    add token
  3. Select Connect.

The CloudBees Slack Integration Plugin is greatly enhanced when it can gather information from others plugins including:

After you have set up CloudBees Core Personalized Slack Messaging in the Slack App API and CloudBees Core, you need to configure users so that they can start receiving messages.