Slack notification in Jenkins pipeline

Gabriele de Capoa
1 min readApr 12, 2021
Photo by Austin Distel on Unsplash

I’m starting to approach to CI/CD world and I found Jenkins is a good tool.

As first step I’ve created a lot of jobs to perform various steps of CI/CD pipeline, but now I discovered Jenkins pipeline features…and that was great! I could refactor all jobs in order to have under control all steps of deployment.

Bw the way, it is not feasible to have a browser tab always open to Jenkins pipeline UI, so best practice is to include some notification steps into your pipeline script.

I choose to use Slack to notify when pipelines completes successfully or fails. To do that, it is necessary to have installed Slack plugin into you Jenkins server; this plugin allows to use slackSend step into your stages.

For example,

<script src=”https://gist.github.com/gabriele-decapoa/d4c2334d7cfcf700d58b7ef06dc43381.js"></script>

clones a git repository and send a message to Slack. To customize your Slack messages, you could read this article.

Originally published at https://gabriele-decapoa.github.io.

--

--

Gabriele de Capoa

Cloud software engineer, wanna-be data scientist, former Scrum Master. Agile, DevOps, Kubernetes and SQL are my top topics.