DevOps Automation

 View Only

Integrating Slack with IBM DevOps Deploy Using Webhooks: A Simple Guide

By ShreyaDilip Dhapke posted Wed September 18, 2024 04:44 PM

  

Integrating Slack with IBM DevOps Deploy Using Webhooks: A Simple Guide

In today’s fast-paced development environment, effective collaboration and timely notifications are crucial for a smooth workflow. IBM DevOps Deploy helps us by offering email notifications and working with tools like Slack. 

With the webhooks feature, you can easily set up notifications and automate tasks, making your process more flexible. Webhooks allow you to customize alerts, so everyone stays informed about the deployments.

Here’s a step-by-step guide to integrate Slack with IBM DevOps Deploy using Webhooks:

Step 1: Create an Incoming Webhook app in Slack

The first step in integrating DevOps Deploy with Slack is to create an incoming webhook in Slack. This webhook will act as a bridge between DevOps Deploy and your Slack workspace, allowing notifications to be sent directly to your Slack channels.

1. Navigate to https://api.slack.com and click on Your Apps, then click on Create New App.

2. After you click on Create New App. It will ask for two options.

I have selected the From scratch option here:

3. Enter the name for your app and select your Slack workspace where the notifications will be sent.

Example: I am creating an app named ‘Test-Webhook’ and I want it to send notifications to my slack workspace called ‘Test’.

 

4. After creating your application, navigate to the Incoming Webhooks section in the application settings and enable the Activate Incoming Webhooks option.

5. Click on Add New Webhook to Workspace and choose the Slack channel where you want the notifications to appear and click Allow

Here I want the notification to appear in the Slack channel named test.

6. After setting the incoming webhooks, you’ll get a webhook URL. Copy this URL as it will be required to link DevOps Deploy with Slack.

Step 2: Define the Message Layout

Next, you need to define how the messages will look when they arrive in Slack. This involves creating a JSON layout that specifies the content and format of your notifications.

A message layout is defined in a JSON format that includes the message in text, links, and image, if required. For DevOps Deploy, you can create a 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. You can refer to the below URL for the sample JSON templates used in slack.

https://www.ibm.com/docs/en/devops-deploy/8.0.1?topic=slack-message-layout-templates

Step 3: Create a Webhook Template

Once you have your JSON layout ready, the next step is to create a webhook template in IBM DevOps Deploy. This template will use the JSON layout to format notifications for specific events.

1. Go to Settings > Automation > Webhook Templates > Create Webhook Template in IBM DevOps Deploy UI.

2. Give your template a name. I have given the name as Application process success notification.

3. Then click on Body and paste the JSON layout you have created for the application process success.

4. Select Event Type “Process Success” as the event type for this template.

5. Click Submit to create the webhook template.

Step 4: Add the Webhook Template to an Application

Finally, you need to link the webhook template to your IBM DevOps Deploy application. This step ensures that notifications are sent to Slack whenever the specified event occurs.

1. Ensure your application has an environment and resources set up.

2. Navigate to Applications > [your application] > Configuration > Webhooks > Add Webhook.

I have an application named as Webhooks-application to get the notification about the successful process deployment.

3. Enter the Webhook Details:

   - URL: Paste the Slack webhook URL you copied earlier.

   - Event Type: Select “Process Success”.

   - Template Name: Choose the template you created.

   - Environment: Specify the environment for the application.

4. Click Add to finalize the integration.

5. Once these steps are completed, DevOps Deploy will automatically send notifications to your Slack channel according to the webhook template. 

In this blog, if an application process is successful, the test slack channel will receive a notification with details about the successful deployment, including a description and a link to view more information about it.

Sample Output

0 comments
58 views

Permalink