How-to: Integrate Slack

Integrate Slack with HCL DevOps Deploy (Deploy) to post notifications automatically to your Slack app whenever a specific deployment event happens.

About this task

Walk through a scenario and learn how to push messages to Slack when an application process fails to deploy in Deploy.

In this example, you'll learn about the requirements and procedure to integrate Slack with Deploy. To integrate Slack with Deploy, follow the steps provided in this section:

Step 1: Create an incoming webhook app in Slack

Procedure

  1. Go to api.slack.com and click Create an App.
  2. Provide an App Name and choose an appropriate workspace.
  3. After you create the app, go to Incoming Webhooks.
  4. Turn on Activate Incoming Webhooks, and click Add New Webhook to Workspace.
  5. Choose a Slack channel that you want the post the messages to.
  6. Click Allow.
  7. Copy and save the generated webhook URL.

Results

The webhook is added to the Slack app and posts a confirmation message in the app.
Note: For additional information about incoming webhooks for Slack, refer to the Slack documentation.

Step 2: Define the message layout

A message layout is defined in a JSON format that includes the message in text, links, and image, if required. For HCL DevOps Deploy (Deploy), you can create message layout that refers to the process name, status, and a link to the process deployment page. This message layout is used in the webhook template. Message layout is defined differently for each event type.

About this task

The message layout is available for the following events:

Step 3: Create a webhook template

Create a webhook template for an application process failure so that when the event happens a notification is triggered in your Slack app.

Procedure

  1. Select Settings > Webhook Templates > Create Webhook Template.
  2. Provide a name and description for the template. For this example, give the name as Application process failed notification.
  3. Click on Body and paste the example Application Deployment Failure JSON body from the step 2.
  4. Choose the event type Process Failure from the Type field.
  5. Submit your changes.

Results

The webhook template is created and ready to be added to an application.

Step 4: Add the webhook template to an application

You can add a webhook template to applications, generic processes, and external approval processes. For this example, you add the template to an application.

Before you begin

Make sure that you have created an environment for the application and have resources added to it.

Procedure

  1. Select Applications > application name > Configuration > Webhooks > Add Webhook.
    The Add Webhook window is displayed.
  2. Copy the URL that you generated from step 1 and paste it in the URL field.
  3. Specify the event type as Process Failure.
  4. Select the template name created in step 3 from the Webhook Template field.
  5. Specify the environment name from the Environments field.
  6. Submit your changes.

Results

The webhook template is added to the application. When the application process runs on the environment and fails, the Slack app shows the following example notification.

Slack example notification for approval failed event

Webhook-Integration-Test 6/13 6:53 PM
An approval failed for the App application on the Env environment
An application process was rejected during its approval process
Application: App Environment: Env Requested by: admin Scheduled for: Sun Jun 13 18:52:31 IST 2021 Description: ${request.Description}
Click View Details for more information.