Configure Slack to receive notifications about your Tekton Pipeline
Learn how to configure a DevOps delivery pipeline and integrate Slack into your toolchain to receive notifications whenever there are any updates to the Tekton pipeline
Join the DZone community and get the full member experience.Join For Free
In this post, you will create a NodeJS Express starter app, configure a DevOps delivery pipeline and integrate Slack into your toolchain to receive notifications whenever there are any updates to the Tekton pipeline.
Before you begin, let's quickly learn about Tekton and Slack,
What is Tekton?
Tekton is an open-source, vendor-neutral framework for creating continuous integration and delivery (CI/CD) systems, governed by the Continuous Delivery Foundation (CDF). As a Kubernetes-native framework, Tekton helps to modernize continuous delivery by providing industry specifications for pipelines, workflows, and other building blocks - making deployment across multiple cloud providers or hybrid environments faster and easier.
IBM provides a seamlessly managed CI/CD experience with Tekton pipelines in IBM Cloud Continuous Delivery toolchains, so you can deliver cloud-native applications across multiple cloud providers or on-premises systems, monitored by an integrated dashboard.
Now, let's understand a bit about Slack
What is Slack?
Slack is a cloud-based, real-time messaging and notification system. Slack provides persistent chat, which is a more interactive alternative to email for team collaboration. You can communicate with your team on a dedicated channel or on a set of channels that are directly related to your work. The communications in direct messages and on channels are retained so that you can search them.
Notifications that are posted to public Slack channels are visible to everyone on the team. You can configure Slack to receive notifications about your toolchain from the in-built tool integrations.
- Create a Continuous Delivery service instance
- Set up a registry namespace
- Create a Code Engine project
- Getting started with Slack Incoming Webhooks (complete steps 1-3 in the section and save the Webhook URL for future access)
Create a starter application
IBM Cloud App development offers a selection of starter applications to generate all the necessary boilerplate, build and configuration code so that you can start coding business logic faster:
- From the IBM Cloud console, use the left-side menu option and select App Development.
- Click Starter Kits.
- Select the Node.js Express App tile, click on Get Started and then Create app to create a Node.js starter application.
- Enter a unique name for the application, such as <your-initials>-nodejs-code-engine-app, and select a resource group. Then, click Create.
Configure DevOps delivery pipeline
Now that you successfully created the starter application, you can automate its deployment to the Code Engine project.
IBM Cloud Code Engine is a fully managed, serverless platform that runs your containerized workloads, including web apps, microservices, event-driven functions, or batch jobs. Code Engine even builds container images for you from your source code. Because these workloads are all hosted within the same Kubernetes infrastructure, all of them can seamlessly work together. The Code Engine experience is designed so that you can focus on writing code and not on the infrastructure that is needed to host it:
- Under the Deployment Automation tile, click on Deploy your app.
- Select Code Engine as the Deployment target. The other targets are Kubernetes Service, Red Hat OpenShift and Cloud Foundry.
- Provide an IBM Cloud API Key. If you don't have one, create one by clicking on New.
- Select a Container registry region and a Container registry namespace.
- Select a region same as your Code Engine project in which to create your toolchain.
- Select the Code Engine project name you created earlier.
- Click Next:
- Change the DevOps toolchain name if you wish to, check the region and click on Create.
- Click on the name of the toolchain under Deployment Automation to see the overview page of the toolchain.
Configure Slack to receive notifications about your toolchain
A toolchain is a set of tool integrations that support development, deployment, and operations tasks. The collective power of a toolchain is greater than the sum of its individual tool integrations:
- On the Overview page of your toolchain, click on Add tool.
- Click Communication on the left pane and then click on the Slack tile.
- On the configure Slack page, enter the Webhook URL under Slack Webhook and the Slack channel name (without #). You can always find the Slack Webhook URL and channel name under the Incoming Webhooks page of your Slack app.
- For the Slack team name, navigate to the Slack app and click on the workspace name on the top-left corner, as shown in the screenshot below. Enter the name without .slack.com. For example, the Slack team name is test-zam6729 .
- Click on Create integration. You should see message Webhook configuration details in the channel you specified, creating the Slack integration as shown in the image below:
Configure the delivery pipeline to send notifications to Slack
- Under the Overview page of your toolchain, click on Delivery pipeline and the ci-pipeline tile.
- On the left pane, click on Definitions.
- Click on Add for a new definition:
- Under repository, select <toolchain-name>-tekton-catalog
- Branch: master
- Path: slack
- Click on Add
- Repeat Step 3 with Path: slack/sample.
- You should now see two new definitions added pointing to slack and slack/sample.
- You can validate the pipeline definition by clicking Validate to see "No errors or warnings detected."
- Click on Save.
- Navigate to Settings, switch Slack notifications to On and click Save.
- Click on Run Pipeline to trigger the toolchain and then click on Run.
The code update triggers a build, but to quickly test whether the Slack integration is working, you can create a manual trigger to start the sample listener by following these steps:
- Click on Triggers > Add Trigger > Manual:
- EventListener: event-listener-post-slack
- Clickon Save
- Click on Run Pipeline > Select Manual Trigger - 1 and then click on Run:
You can cross-check the Slack messages with the PipelineRuns, as shown below:
Published at DZone with permission of Vidyasagar Machupalli, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.