Use cases
We have divided the Use cases section into two parts. In the first part, we will build a library for sending pre-formatted Slack messages. This is the most commonly used shared library code pattern for providing a globally useful helper function. In the second part, we will develop our own DSL using the shared libraries in three different ways. This is a more advanced use case that will be useful in scaling your Jenkins instance. Let's get started.
Code reuse via global variables – Pre-formatted Slack messages
Required plugins
Slack Notification
Let's create a helper function that sends a Slack message in a standard format.
Prepare the Jenkins integration for Slack
Before starting, we need to configure Slack with Jenkins CI app so that it can receive messages from Jenkins:
- On Slack, click Apps, search for
Jenkins CI
, then click Add: