A Buildkite plugin written in Go to send job and build notifications formatted for Discord using Discord Webhooks.
This plugin works similarly to the notify
attribute in a command step.
You can create a webhook integration in your Discord guild following the steps here.
The plugin has been tested and built using go 1.20.3.
###polyglot-hooks
experiment to be enabled on your agents.
Add the following to your pipeline.yml
:
steps:
command: ./build.sh
plugins:
discord-notifications#v0.1.0:
message: "From Buildkite with Love"
webhook-url: DISCORD_WEBHOOK_URL
The plugin builds a pre-exit
hook in the /hooks directory, and when executed, will check the exit status of the job's command hook, and send a formatted message to the configured Discord Webhook URL based on the result.
Below are a list of exmaples that you can use to implement the plugin in your pipelines.
The message you want to send in the notification
The environment variable that contains the value of the Discord Webhook URL. Default: DISCORD_WEBHOOK_URL
.
It is not recommended to pass secure
The tests are written using Go's built-in testing package, as well as using packages from stretchr/testify.
Tests can be run from the command line:
go mod tidy
go test -v ./...
We welcome all contributions to improve the plugin! To contribute, please follow these guidelines:
- Fork the repository and create a new branch.
- Make your changes and ensure that the tests pass.
- Write clear and concise commit messages.
- Submit a pull request.
By contributing, you agree to license your contributions under the LICENSE file of this repository.
MIT (see LICENSE)