Skip to main content

Integrate Slack notifications in your OpenShift pipeline

In this blog I’ll describe how to configure Slack notifications to alert failures and success in your OpenShift Jenkins pipeline. Huge shoutout to Chak from Red Hat who inspired this blog. The code from this repo is contributed to Chak’s repo and is built on his instructions.

Create OpenShift Pipeline:

After logging into OpenShift, create a new project and run:

$ oc process -f | oc create -f -

The link to the pipeline code is here

This should create a pipeline called openshift-slack-pipeline in your OpenShift Pipelines:

Next, navigate to Applications -> Routes and click on the jenkins route. this route is dynamically created upon creation of the OpenShift pipeline

Create a token for Slack:

Navigate to choose your workspace and a Slack channel where you want the notifications to appear.

Follow setup instructions from Slack:

In the resulting page, setup instructions will be provided from Slack to integrate it with Jenkins. Your Global Slack Notifier Settings should look like this:

Run the pipeline:

Navigate to Builds -> Pipelines -> Start Pipeline next to openshift-slack-pipeline

The pipeline should fail on stage Build as it is expecting an already present buildconfig:

At the same time, you should also see a Slack message indicating that the build has failed:

Deploy the application:

Run the following command to deploy a test app for the pipeline:

$ oc new-app --name=weather-app

Run the pipeline again:

Now that there is a weather-app deployment and build present, the pipeline should succeed and should send Slack notificatons indicating success:

And there you have it! This was a quick tutorial on how to integrate Slack notifications in your OpenShift Jenkins pipeline. This example is pretty basic to show the functionality and can be built further to do multi-project deployment as well as multi-cluster deployments.

Share this story

Arctiq Team

We service innovation.