SlackOps Interactive Notification

Introduction

Approving or rejecting Manual Judgement constraints from Slack.

The user can set up SlackOps Interactive notifications in your delivery config, which will enable interactive notifications to a Slack channel of your choice, where you can simply click a button to approve or reject the deployment of the artifact into the environment.

Create Slack App

There are two ways to create a Slack app as mentioned below. Users can choose any one of the methods to create an application.

  • Create an application “From Scratch

  • Create an application “From an app manifest”.

Creating Slack App From Scratch

Go to this URL https://api.slack.com/apps and proceed with the below steps.

  1. Click “Create an App” to

2. Click on “From scratch” in the pop up window as shown below:

3. Type your “App Name” and “Pick a workspace to develop your app in” from the dropdown and then click “Create App”.

4. Click on “Interactive Components” to Configure Spinnaker gate Callback API Endpoint in Slack.

5. “Turn on” interactivity and enter the Spinnaker gate url in the Request URL column and then click “Save Changes”. For Example: (https://<your-domain-name>/notifications/callbacks/slack).

6. Click “OAuth & Permissions” from the navigation menu.

7. Click on “Add an Oauth Scope”.

8. For bot token select “users:read, users:read.email, chat:write” from the drop down.

Your application is now ready to be installed in the workspace and added to Slack channels.

Creating Slack App From an app manifest

Go to this URL https://api.slack.com/apps and proceed with the below steps.

  1. Click “Create an App”

2. Click on “From an app manifest” in the pop up window as shown below:

3. Select a workspace and click “Next

4. “Enter app manifest” window will appear as shown below:

5. Update the App Name, display name for your slack app and the following manifest data in the “Enter app manifest” window as shown in the above image and click “Next”.

display_information:
 name: <your app name>
features:
 bot_user:
  display_name: <your app display name>
  always_online: false
oauth_config:
 scopes:
  bot:
   - users:read
   - users:read.email
   - chat:write
settings:
 interactivity:
  is_enabled: true
  request_url: https://<spinnaker gate host>/notifications/callbacks/slack
 org_deploy_enabled: false
 socket_mode_enabled: false
 token_rotation_enabled: false

6. Review the summary and click “Create”

Your application is now ready to be installed in the workspace and added to Slack channels.

Install Slack App

Follow the steps below to install the Slack application into your Slack workspace and add it to your Slack channels.

Go to this URL https://api.slack.com/apps and proceed with the below steps.

  1. Click your application from the list as shown in the below image.

2. Below screen will appear and you can select your application from the drop down in the top left hand side corner. Click “Basic Information” and then click “Install your app” to install your application into the workspace.

3. Click “Install to Workspace“.

4. Select your “Slack Channel” from the drop down and Click “Allow”.

Your application is installed now in the workspace and you need to integrate your application into Slack channels by following the below steps.

Integration to Slack Channel

  1. Go to your Slack application and Click your “Channel Name” from the channel list as shown in the below image. For Example: "#demo_alerts" channel name selected in below steps.

2. Click on channel name “# demo_alerts” to integrate your application as below:

3. After clicking the channel name below screen will appear and click “Integrations” tab.

4. Click “Add an App” button from the integration window.

5. Search “SlackOps” from the App Directory and click “Add” as shown in the below image.

6. Now your application is Integrated with Slack Channel as shown in the below image and you will get notification in the selected channels.

Configure Spinnaker

Application Credentials required for spinnaker echo local configuration. These credentials will be generated automatically when your application is created, and you can find them in your application's Basic Information.

  1. Click On “Basic Information” for your app and scroll down to see the “App Credentials

Note: Make sure that you have selected the correct application name from the top left hand side as shown in the above image.

2. The App Credentials window displays all the required credentials as shown below.

Note: These credentials allow your app to access the Slack API. They are secret. Please don't share your app credentials with anyone, include them in public code repositories, or store them in insecure ways.

3. Click “OAuth & Permissions” copy bot token from “Bot User OAuth Token” box. (Note: Bot token will get generated when you install your app in the slack workspace).

4. Update the /home/spinnaker/.hal/config file with following details. You can see the token details from the above image and paste it here.

slack:
  enabled: true
  token: "xoxb-****************-****************"
  botName: "<your app name>"

5. Update the /home/spinnaker/.hal/default/profiles/echo-local.yml file with following details. Update your “Token and Signing_secret” details from the “Bot User OAuth Token & App Credentials” as explained in the steps 2 & 3.

slack:
  app:
   token: "xoxb-**********-***********-*******************"
   signing_secret: "********************"
hal deploy apply

6. Go to your application in the Spinnaker and click “Pipeline” and click “Configure a new pipeline” as shown in the image below.

7. Provide your “Pipeline Name” and click “Create”.

8. Click “Add Stage” and select type as “Manual Judgement” from the drop down.

9. Select “Send Notifications” option and Click “Add Notification Preference” in your pipeline manual judgement stage.

10. Select Notify via as “Slack” from drop down and provide your Slack Channel name. The application must be integrated with Slack, and notifications will be sent to that channel.

11. Select the options when the notification should execute and click Update as below shown in the above image.

12. When a user trigger a pipeline, they will receive a Slack notification asking them to approve or reject a particular stage, as shown below:

The pipeline will proceed to the next stage or be rejected in a specific stage based on the response as "Approve/Reject."

Last updated