Use Case :
When we receive a build notification in Slack the default message looks like this
" success <|/#04defa23> (main) by"
Which contains very basic information about the build. With Drone slack plugin we can send custom message with more information about the build like who triggered the pipeline, branch name, git user email and much more using built in CI codebase Variables and pipeline variables.
Plugin step settings : Plugins are Docker containers that are set up as steps in your stage and carry out specific activities. Among other things, plugins can be used to publish artefacts, provide notifications, and deploy code.
Sending a custom build slack notification using custom plugin step
Step 1: Configuring a custom plugin step for sending a slack notification in Harness is a seamless two step process after creating after Creatig a Slack App and Webhook for your channel (Send Notifications Using Slack - Harness.io Docs)
Add the custom plugin step in your pipeline, we will be using Drone slack plugin for our use case.
Name the Docker image used : plugins/slack, and provide the slack webhook URL and channel name.
Step 2 : Here’s our final goal to send a build info with our own custom message and to achieve it we will be using drone slack plugin image PROPERTIES (Drone Plugins - Slack) template
template is used overwrite the default message template.
We will be using harness expression to send info about branch name, who triggered the pipeline (manually from Harness UI or with Trigger), commit sha, or git user email id.
One thing to note here to avoid null in the messages while using the custom variable is that we have to user variables depending upon the build if the build is manually ran or using triggered using git trigger.
For manual builds to send a message that contains branch info and the user info who executed the pipeline we will use following expression.
Pipeline executed by <+pipeline.triggeredBy.email>
Branch info <+codebase.branch>
For Builds from Git Webhook Triggers :
To use more expression based upon the build type please have a look into this
Built-in CI Codebase Variables Reference - Harness.io Docs.
Happy building, deploying and much more with Harness