There are thousands of CI/CD tool out there! And it’s increasing every day I believe. I got chance to work with a few CI/CD tool myself, they are namely Jenkins, Bamboo CI, Go CD, Travis CI, Team City, VSTS and now working with Drone CI in my current organization where I am serving as QA Lead.
Time to time I require to configure new pipeline or some time needs to add an additional feature to the existing pipeline. I am not going to the detail of how to play with .drone.yml to create pipeline or update existing pipeline. This post is particularly for the audience who are working with Drone CI and at some point wanted to have some notification from Drone CI regarding the pipeline build status. Others feel free to read ahead (no harm to learning new stuff, right? 😀 ).
Assumptions
- You are well familiar with slack, slackbot and concept of slack notification.
- You are familiar with Drone CI pipeline (at least basic concept like how to trigger, events and such).
- You know what Docker image is :).
Setup
Slackbot
Drone CI Step
slack-notify:
image: plugins/slack
secrets: [slack_webhook]
webhook: $slack_webhook
channel: your-channel-name
template: >
{{#success build.status}} ✔ {{ else }} :x: {{/success}} {{ uppercasefirst build.status }}: Build #{{ build.number }} * (type: `{{ build.event }}`)
Commit: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commit/{{ build.commit }}|{{ truncate build.commit 8 }}>
Branch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>
Author: {{ build.author }}
Build: <{{ build.link }}| Drone Build {{ build.number }} ↗>
when:
status: [ success, failure ]
branch: [ master, develop ]
- image: The docker image we are pulling into our drone CI agent to send any notification.
- secrets: I have provided the webhook URL as the secret in the drone pipeline and providing the secret name (https://docs.drone.io/secret/).
- webhook: Supposed to be the URL you have copied from your slack API page earlier, but here I am just using the secret name with a “$” sign, to define it as a parameter which will be replaced with the actual value during the pipeline execution time.
- channel: Name of the slack channel where you would like this alert to be posted.
- template: To beautify the message with proper formatting and information regarding your build and repo.