Code Monkey home page Code Monkey logo

travis-ci-discord-webhook's Introduction

Travis CI 🡒 Discord Webhook

Backers on Open Collective Sponsors on Open Collective

If you are looking for a way to get build (success/fail) status reports from Travis CI in Discord, stop looking. You've came to the right place.

I was waiting for the Travis team for a long time to integrate Discord Webhook support to their build notifications, but they don't seem to be doing anything about that. So I made these script to just do the same.

No need to wait for them to add Discord Webhook Integration, rest aside and just follow the guide below and stay notified of your build status.

Requirements

  • You should be using Travis CI for testing codes.
  • A Discord Server where notifications will be posted.
  • 5 minutes
  • A cup of coffee ☕

Guide

  1. Create a webhook in your Discord Server (Guide).

  2. Copy the Webhook URL.

  3. Go to your repository settings (for which you want status notifications) in Travis CI and add an environment variable called WEBHOOK_URL and paste the Webhook URL you got in the previous step. You can also specify multiple webhook addresses at once, separating each with a whitespace character, such as space.

    Add environment variable in Travis CI

  4. Add these lines to the .travis.yml file of your repository.

    after_success:
      - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
      - chmod +x send.sh
      - ./send.sh success $WEBHOOK_URL
    after_failure:
      - wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
      - chmod +x send.sh
      - ./send.sh failure $WEBHOOK_URL
  5. Grab your coffee ☕ and enjoy! And, if you liked this, please ⭐Star this repository to show your love.

Note

  • If you face any issues in the scripts (and you're sure it's not on your side), please consider opening an issue and I'll fix it ASAP.
  • If you want to improve the scripts, feel free to open a pull request.

See Also

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

travis-ci-discord-webhook's People

Contributors

bluexin avatar gpkc avatar iamtraction avatar intrigus avatar justarchi avatar mariohoyos92 avatar mateuszdrwal avatar mindgamesnl avatar monkeywithacupcake avatar vbrown37 avatar zethzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

travis-ci-discord-webhook's Issues

Notifications sent twice in the discord channel

Hi guys, great work for this !

I've been using your script to send webhook notifications to my discord server when travis complete the build, but weirdly enough, it seems the notifications are sent twice.
Moreoever, the build numbers do not match the one I got on my travis dashboard.

Here is a screenshot of the notifications received :

image

And here is the screenshot of the travis related dashboard :

image

Are you aware of this and if yes, do you know how to fix this ?

Private webhook makes WEBHOOK_URL unavailable to forked PRs

This is related to #2. My team just started using this project yesterday and it works great for pushes to the branch. However, we also want to receive Discord pass/fail notifications for builds from forked pull requests. Currently, the WEBHOOK_URL is empty to PRs from forks. This is by design per https://docs.travis-ci.com/user/environment-variables#Defining-Variables-in-Repository-Settings.

Considering the aim of this project is to get notifications to Discord, is there any way around this other than adding the webhook URL to .travis.yml? This will make the webhook URL available to forks, but is also potentially insecure.

Thank you for any insight that you can offer.

Multiple Discord Hook Support

Hi i want to request support to multiple discord hooks, its awesome and its so great how this works, maybe a recursive WEBHOOK_URL Env Variable recognition or array?

Keep the good work 👍

Not recieving anything in discord

I've tried to set up the discord webhook but can't get anything through to the dicsord server. I followed the steps in the readme. I used my own discord server and set up the webhook so it shouldn't be a permission issue. I changed the url to the verbose version as suggested in #16 but appears no different to me

This is my config file:
https://github.com/jonakirke94/GTL_demo/blob/master/.travis.yml

Example of failed build:
https://travis-ci.org/jonakirke94/GTL_demo/builds/525564948

Example of successful build:
https://travis-ci.org/jonakirke94/GTL_demo/builds/525563528

[Suggestion] Trunc long commit message because it's causing an error 400 (Bad request)

Hello !

I've experienced an error 400 and after test it, it's due to a long commit message. I discover the issue with a commit message of 277 characters. It can be to be reproduce any time.
After reading the documentation on discord developer portal:

Additionally, the characters in all title, description, field.name, field.value, footer.text, and author.name fields must not exceed 6000 characters in total. Violating any of these constraints will result in a Bad Request response.

The idea is modify the script to trunc the commit message when it's exceed a length of 200 (I try with 260 characters, same issue. It can be passed with 250 characters. So 200, seems not bad). For taking in consideration long repo name, long user name, etc

Escape `"` characters in the embed titles

It always fails to send build webhooks both on GitHub's side (build notifications doesn't arrive on Discord with 400 code) and sometimes in Travis (your code says curl: (22) The requested URL returned error: 400 and Unable to send webhook)

Is it possible to retry until Discord finally accepts the sent webhook (probably 3-5 times)?

Update links to repo

Since this repo is now moved to the DiscordHooks org., we should now update all the links in this repo from k3rn31p4nic/travis-ci-discord-webhook to DiscordHooks/travis-ci-discord-webhook.

PRs are welcome.

400 BAD REQUEST (umlaut related?)

Hey, I'm trying the webhook, but it doesn't work.
It seems to work perfectly fine when using English only commit descriptions but I have to be able to use german language and umlauts, i.e. öäüß.
This is the log I get when I used the verbose version ( https://github.com/intrigus/travis-ci-discord-webhook/blob/master/send.sh ).
I also attached a log of a working commit.

Failing version:

(Has umlauts and is multiline - maybe multiline is the culprit?)

[0K$ ./send.sh failure $WEBHOOK_URL
[Webhook]: Sending webhook to Discord...

START WEBHOOK_DATA
{
"username": "",
"avatar_url": "https://travis-ci.org/images/logos/TravisCI-Mascot-1.png",
"embeds": [ {
"color": 15158332,
"author": {
"name": "Job #1.1 (Build #1) Failed - intrigus/pse2019",
"url": "https://travis-ci.com/intrigus/pse2019/builds/111121611",
"icon_url": "https://travis-ci.org/images/logos/TravisCI-Mascot-red.png"
},
"title": "[CI] Travis Konfigurationsdatei hinzugefügt.",
"url": "",
"description": "Zeile 3-9 ist die von Travis empfohlene Standardkonfiguration, um Probleme
mit dem Caching zu vermeiden, wenn man Gradle verwendet.
Der Rest ist zuständig für die Integration mit unserem Discord-Server.\n\nintrigus authored & GitHub committed",
"fields": [
{
"name": "Commit",
"value": "6332f65",
"inline": true
},
{
"name": "Branch/Tag",
"value": "master",
"inline": true
}
],
"timestamp": "2019-05-08T22:40:51Z"
} ]
}
END WEBHOOK_DATA

  • Hostname was NOT found in DNS cache
  • Trying 104.16.58.5...
  • Connected to discordapp.com (104.16.58.5) port 443 (#0)
  • successfully set certificate verify locations:
  • CAfile: none
    CApath: /etc/ssl/certs
  • SSLv3, TLS handshake, Client hello (1):
    } [data not shown]
  • SSLv3, TLS handshake, Server hello (2):
    { [data not shown]
  • SSLv3, TLS handshake, CERT (11):
    { [data not shown]
  • SSLv3, TLS handshake, Server key exchange (12):
    { [data not shown]
  • SSLv3, TLS handshake, Server finished (14):
    { [data not shown]
  • SSLv3, TLS handshake, Client key exchange (16):
    } [data not shown]
  • SSLv3, TLS change cipher, Client hello (1):
    } [data not shown]
  • SSLv3, TLS handshake, Finished (20):
    } [data not shown]
  • SSLv3, TLS change cipher, Client hello (1):
    { [data not shown]
  • SSLv3, TLS handshake, Finished (20):
    { [data not shown]
  • SSL connection using ECDHE-RSA-AES128-GCM-SHA256
  • Server certificate:
  • subject: OU=Domain Control Validated; OU=PositiveSSL; CN=discordapp.com
  • start date: 2017-02-24 00:00:00 GMT
  • expire date: 2020-03-11 23:59:59 GMT
  • subjectAltName: discordapp.com matched
  • issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
  • SSL certificate verify ok.

POST /api/webhooks/575808920900206594/ggjFSI36Qsf6RodG26LGUlMEjLGVYI9-Y1kgwoDVm0YXfL5LdG3Y0TlV6MnLGTVMbIZV HTTP/1.1

User-Agent: TravisCI-Webhook

Host: discordapp.com

Accept: /

Content-Type:application/json

X-Author:k3rn31p4nic#8383

Content-Length: 1120

Expect: 100-continue

< HTTP/1.1 100 Continue

} [data not shown]

######################################################################## 100.0%* The requested URL returned error: 400 BAD REQUEST

  • Closing connection 0
  • SSLv3, TLS alert, Client hello (1):
    } [data not shown]

curl: (22) The requested URL returned error: 400 BAD REQUEST

[Webhook]: Unable to send webhook.

Working version with different subject&description#

�[0K$ ./send.sh failure $WEBHOOK_URL
[Webhook]: Sending webhook to Discord...

START WEBHOOK_DATA
{
"username": "",
"avatar_url": "https://travis-ci.org/images/logos/TravisCI-Mascot-1.png",
"embeds": [ {
"color": 15158332,
"author": {
"name": "Job #5.1 (Build #5) Failed - intrigus/pse2019",
"url": "https://travis-ci.com/intrigus/pse2019/builds/111124240",
"icon_url": "https://travis-ci.org/images/logos/TravisCI-Mascot-red.png"
},
"title": "Umlaut-Test äöü",
"url": "",
"description": "\n\nintrigus authored & GitHub committed",
"fields": [
{
"name": "Commit",
"value": "2e9580e",
"inline": true
},
{
"name": "Branch/Tag",
"value": "ci-debug-test",
"inline": true
}
],
"timestamp": "2019-05-08T22:53:12Z"
} ]
}
END WEBHOOK_DATA

  • Hostname was NOT found in DNS cache
  • Trying 104.16.58.5...
  • Connected to discordapp.com (104.16.58.5) port 443 (#0)
  • successfully set certificate verify locations:
  • CAfile: none
    CApath: /etc/ssl/certs
  • SSLv3, TLS handshake, Client hello (1):
    } [data not shown]
  • SSLv3, TLS handshake, Server hello (2):
    { [data not shown]
  • SSLv3, TLS handshake, CERT (11):
    { [data not shown]
  • SSLv3, TLS handshake, Server key exchange (12):
    { [data not shown]
  • SSLv3, TLS handshake, Server finished (14):
    { [data not shown]
  • SSLv3, TLS handshake, Client key exchange (16):
    } [data not shown]
  • SSLv3, TLS change cipher, Client hello (1):
    } [data not shown]
  • SSLv3, TLS handshake, Finished (20):
    } [data not shown]
  • SSLv3, TLS change cipher, Client hello (1):
    { [data not shown]
  • SSLv3, TLS handshake, Finished (20):
    { [data not shown]
  • SSL connection using ECDHE-RSA-AES128-GCM-SHA256
  • Server certificate:
  • subject: OU=Domain Control Validated; OU=PositiveSSL; CN=discordapp.com
  • start date: 2017-02-24 00:00:00 GMT
  • expire date: 2020-03-11 23:59:59 GMT
  • subjectAltName: discordapp.com matched
  • issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
  • SSL certificate verify ok.

POST /api/webhooks/575808920900206594/ggjFSI36Qsf6RodG26LGUlMEjLGVYI9-Y1kgwoDVm0YXfL5LdG3Y0TlV6MnLGTVMbIZV HTTP/1.1

User-Agent: TravisCI-Webhook

Host: discordapp.com

Accept: /

Content-Type:application/json

X-Author:k3rn31p4nic#8383

Content-Length: 901

} [data not shown]

######################################################################## 100.0%* upload completely sent off: 901 out of 901 bytes
< HTTP/1.1 204 NO CONTENT

< Date: Wed, 08 May 2019 22:53:13 GMT

< Content-Type: text/html; charset=utf-8

< Content-Length: 0

< Connection: keep-alive

< Set-Cookie: __cfduid=d6c5a602a1b95cec234239559d46d35141557355993; expires=Thu, 07-May-20 22:53:13 GMT; path=/; domain=.discordapp.com; HttpOnly

< Strict-Transport-Security: max-age=31536000; includeSubDomains

< X-RateLimit-Limit: 5

< X-RateLimit-Remaining: 4

< X-RateLimit-Reset: 1557355996

< Via: 1.1 google

< Alt-Svc: clear

< Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"

  • Server cloudflare is not blacklisted
    < Server: cloudflare

< CF-RAY: 4d3f022c3f147159-ORD

<

  • Connection #0 to host discordapp.com left intact

[Webhook]: Successfully sent the webhook.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.