If you've been looking for a way to get build reports from your CI service to Discord, look no further. You've come to the right place.
The following CI services are currently supported and will be autodetected when you run the appropriate send.XXX
script:
CI Service | Script | Support Status |
---|---|---|
AppVeyor | send.ps1 |
|
Jenkins | send.ps1 send.sh |
|
Travis | send.sh |
We're always looking to support more! Feel free to implement support yourself or open an issue and ask.
-
Create a Webhook in your Discord Server (Guide).
-
Copy the Webhook URL.
-
Go to your CI platform's global or repository specific settings and look for a section entitled Environment or Environment Variables
-
Add an environment variable named
WEBHOOK_URL
and paste the copied Webhook URL from the previous step.It's wise to keep this URL private.
Most platforms support Secure Environment Variables, offer some form of encryption, or allow you to prevent the value from showing in the build logs entirely.
Example from Travis CI
-
Add the following commands to the
success
andfailure
sections of your CI provider's pipeline.Example for AppVeyor
on_success: - ps: Invoke-RestMethod https://raw.githubusercontent.com/symboxtra/universal-ci-discord-webhook/master/send.ps1 -o send.ps1 - ps: if ($env:WEBHOOK_URL.length -ne 0) { ./send.ps1 success $env:WEBHOOK_URL } else { Write-Host "WEBHOOK_URL inaccessible." } # Send Webhook only when secure env vars can be decrypted on_failure: - ps: Invoke-RestMethod https://raw.githubusercontent.com/symboxtra/universal-ci-discord-webhook/master/send.ps1 -o send.ps1 - ps: if ($env:WEBHOOK_URL.length -ne 0) { ./send.ps1 failure $env:WEBHOOK_URL } # Send Webhook only when secure env vars can be decrypted
Example for Travis CI
after_success: - curl https://raw.githubusercontent.com/symboxtra/travis-ci-discord-webhook/master/send.sh > send.sh && chmod +x send.sh - ./send.sh success $WEBHOOK_URL after_failure: - curl https://raw.githubusercontent.com/symboxtra/travis-ci-discord-webhook/master/send.sh > send.sh && chmod +x send.sh - ./send.sh failure $WEBHOOK_URL
The first line downloads the script file and makes it executable (if applicable). The second line sends the webhook.
If you prefer that the script fail and return a non-zero exit code upon any error, strict mode can be enabled by passing strict
as the third parameter to the script. This is mainly intended for testing.
./send.sh success $WEBHOOK_URL strict
On some CI platforms, secure environment variables are not available during third party pull request builds. The webhook will not send notification of these builds.
To prevent your CI build from erroring, the scripts in this repository exit with a non-zero exit code only when strict
mode is enabled. For added safety/sanity, the script call can be wrapped in a length check on WEBHOOK_URL
, as seen in the AppVeyor example, or can be combined with || true
to eat any possible non-zero exit codes.