Add Discord notifications to your TravisCI deployments using webhooks

After searching the TravisCI documentation, I’ve found no options to implement notifications for the deployment of my projects in Discord. Few days ago perhaps, I’ve found a very nice Gist which allow you to do so unofficially just calling a script.

What will you need?

  • Discord user and server, here how to create one, or briefly press plus 🙂
  • Github account
  • TravisCI integration of your project (article here)

After you have all the tools you can start creating a webhook in Discord easily. In the support page you can find further information. Inside your server access to Server Settings > Webhook, keeping in mind to select the channel you want to use if different from #general.

After you have the Webhook, go into your TravisCI project settings and add a variable called WEBHOOK_URL with the URL generated as value. Then update your script from the travis.yml file using the following snippet (originally from this gist):

after_success:
 - chmod +x discord.sh
 - ./discord.sh success

after_failure:
 - chmod +x discord.sh
 - ./discord.sh failure

Finally add the bash script to your project, called discord.sh.
Remember to update the command if you change name.

Below the result:

Nice uh? 🙂

Note: If you have a shared hosting and want to deploy trough TravisCI in the same way, I’ve written an article about it.

Leave a Reply