Giter Site home page Giter Site logo

taupiknr26 / gitlab-telegram-alert Goto Github PK

View Code? Open in Web Editor NEW

This project forked from suchimauz/gitlab-telegram-alert

0.0 0.0 0.0 13 KB

Docker image for gitlab ci/cd for deploy result alerting with telegram bot

License: Apache License 2.0

Shell 85.29% Dockerfile 14.71%

gitlab-telegram-alert's Introduction

Gitlab Telegram Alert

Docker image for send gitlab ci/cd build results to telegram chat with bot

Usage

Set global environment variables in .gitlab-ci.yml:

variables:
  # ... some variables
  PARSE_MODE: 'Markdown'       # Support HTML, default: Markdown
  CHAT_ID: $CHAT_ID            # Set CHAT_ID repository secret
  BOT_TOKEN: $BOT_TOKEN        # Set BOT_TOKEN repository secret
  DISABLE_NOTIFICATION: True   # Default = False

Job for notify success build:

notify_success:
  stage: <stage>
  image: suchimauz/gitlab-telegram-alert:v1.0.0
  variables:
    # For off pulling repository
    GIT_STRATEGY: none
    MESSAGE: |
      ✅ Success build \*$CI_PROJECT_NAME:$CI_COMMIT_BRANCH\*
      $CI_COMMIT_TITLE

      Commit by: \*$CI_COMMIT_AUTHOR\*
      $CI_PIPELINE_URL
  # It's hack :(
  script:
    - /entrypoint.sh
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'

Also for error build:

notify_error:
  stage: <stage>
  image: suchimauz/gitlab-telegram-alert:v1.0.0
  variables:
    # For off pulling repository
    GIT_STRATEGY: none
    MESSAGE: |
      ❌ Error build \*$CI_PROJECT_NAME:$CI_COMMIT_BRANCH\*
      $CI_COMMIT_TITLE

      Commit by: \*$CI_COMMIT_AUTHOR\*
      $CI_PIPELINE_URL
  script:
    - /entrypoint.sh
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
      when: on_failure

Don't forget to add your to the stages section:

variables: 
  #...

stages:
  # some stages
  - <stage>
  
notify_success:
  stage: <stage>
  #...
notify_error:
  stage: <stage>
  #...

Also you can customize your message as you like using environments from gitlab ci/cd: https://docs.gitlab.com/ee/ci/variables/

Success build

✅ Success build repository:branch
Commit message

Commit by: username <[email protected]>
https://gitlab.com/uri_to_pipeline

Error build

❌ Error build repository:branch
Commit message

Commit by: username <[email protected]>
https://gitlab.com/uri_to_pipeline

gitlab-telegram-alert's People

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.