Code Monkey home page Code Monkey logo

gitlab-ci-discord-webhook's Introduction

GitLab 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 GitLab CI in Discord, stop looking. You've came to the right place.

Requirements

  • You should be using GitLab CI.
  • 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 CI/CD settings (for which you want status notifications) in GitLab 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 GitLab See: https://docs.gitlab.com/ee/ci/variables/#via-the-ui

  4. Add these lines, in their appropriate locations, to the .gitlab-ci.yml file of your repository.

    stages:
      - notification
    success_notification:
      stage: notification
      script:
        - wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
        - chmod +x send.sh
        - ./send.sh success $WEBHOOK_URL
      when: on_success
    failure_notification:
      stage: notification
      script:
        - wget https://raw.githubusercontent.com/DiscordHooks/gitlab-ci-discord-webhook/master/send.sh
        - chmod +x send.sh
        - ./send.sh failure $WEBHOOK_URL
      when: on_failure
  5. Grab your coffee ☕ and enjoy! And, if you liked this, please ⭐Star this repository to show your love.

Artifacts

If you'd like to also link the artifacts in the CI Message, set the variable LINK_ARTIFACT to true:

variables:
  LINK_ARTIFACT: true

Make sure that the artifacts are available to download in the success_notification job. If they are produced by a previous one, you can follow this StackOverflow question

Please also note that artifacts are only available, if success_notification has been triggered.

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.
  • If you are using an alpine image, you need to add git and curl packages before running this script.
    # ...
      script:
        - apk add --update git curl
    # ...

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]

gitlab-ci-discord-webhook's People

Contributors

dodopriester avatar iamtraction avatar italosa avatar justarchi avatar

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.