Code Monkey home page Code Monkey logo

slack-notify's Introduction

1. What does this tool do?

This lightweight tools is designed to send slack message written in Golang without any dependancy.

You need to setup SLACK_WEBHOOK which you need to get from slack website. Slack Webhook is a authenticated URL. Detail explaination is here https://api.slack.com/messaging/webhooks

The minimum inputs are SLACK_WEBHOOK and SLACK_MESSAGE which is the text you want to send.

2. What are the configuration option and priority?

2.1 using config file, file name is "slack-notify.yaml" (Priority lowest)

2.1.1 config file search from running directory (./config/slack-notify.yaml)
2.1.2 config file search from running directory (./slack-notify.yaml)
2.1.2 config file search from running directory ($HOME/slack-notify.yaml)
SLACK_WEBHOOK: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
SLACK_ICON: "https://slack.com/img/icons/app-57.png"
SLACK_CHANNEL: "#[chatroom_name]"
SLACK_TITLE: "Title text"
SLACK_MESSAGE: "Hello slack"
SLACK_COLOR: "#00FFFF"
SLACK_USERNAME: "CLTEO"
SLACK_VERBOSE: false

2.2 using env (Priority higher than config file)

SLACK_WEBHOOK="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
SLACK_ICON="https://slack.com/img/icons/app-57.png"
SLACK_CHANNEL="#[chatroom_name]"
SLACK_TITLE="Title text"
SLACK_MESSAGE="Hello slack"
SLACK_COLOR="#00FFFF"
SLACK_USERNAME="CLTEO"
SLACK_VERBOSE=false

2.3 using cli options (Priority highest)

$ slack-notify -h
slack is CLI client tools to send slack message by given simple inputs.
The main input is SLACK_WEBHOOK which you need to get from slack website.
Web hook explain here https://api.slack.com/messaging/webhooks
The minimum inputs are SLACK_WEBHOOK and SLACK_MESSAGE which is the text you want to send.

Usage:
  slack-notify [flags]

Flags:
  -c, --channel string    Slack channel name (default "#chatops")
  -o, --color string      Slack message color #7CD197
  -h, --help              help for slack
  -i, --icon string       Slack icon URL https://slack.com/img/icons/app-57.png
  -m, --message string    Slack message text (default "My slack message")
  -t, --title string      Slack message title
  -u, --username string   Slack message display name
  -v, --verbose           verbose output
  -w, --webook string     Slack webhook url https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX

3. Usage

Running slack-notify in a shell prompt goes like this:
$ export SLACK_WEBHOOK=https://hooks.slack.com/services/Txxxxxx/Bxxxxxx/xxxxxxxx
$ SLACK_MESSAGE="hello" slack-notify
Running the Docker container goes like this:
$ export SLACK_WEBHOOK=https://hooks.slack.com/services/Txxxxxx/Bxxxxxx/xxxxxxxx
$ docker run -e SLACK_WEBHOOK=$SLACK_WEBHOOK -e SLACK_MESSAGE="hello" -e SLACK_CHANNEL=#chatops teochenglim/slack-notify
Gitlab .gitlab-ci.yml

You may to setup variables via CI/CD variables

stages:
- notify

variables:
SLACK_WEBHOOK: https://hooks.slack.com/services/Txxxxxx/Bxxxxxx/xxxxxxxx
SLACK_CHANNEL: deploy

notify:
  stage: notify
  image: teochenglim/slack-notify:latest
  script:
    - 'SLACK_MESSAGE="Message" slack-notify'
Environment Variables
# The Slack-assigned webhook
SLACK_WEBHOOK=https://hooks.slack.com/services/Txxxxxx/Bxxxxxx/xxxxxxxx
# A URL to an icon
SLACK_ICON=http://example.com/icon.png
# The channel to send the message to (if omitted, use Slack-configured default)
SLACK_CHANNEL=example
# The title of the message
SLACK_TITLE="Hello World"
# The body of the message
SLACK_MESSAGE="Today is a fine day"
# RGB color to for message formatting. (Slack determines what is colored by this)
SLACK_COLOR="#efefef"
# The name of the sender of the message. Does not need to be a "real" username
SLACK_USERNAME="Bot"

4. docker build

Build It

Compile:

make build

Publish to DockerHub

make docker-build docker-push

5. Special thanks

Jeremy Liu https://github.com/Ksloveyuan

https://github.com/krom/slack-notify/

https://github.com/easonlin404/go-slack/

slack-notify's People

Contributors

teochenglim avatar

Watchers

James Cloos avatar  avatar  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.