Giter Site home page Giter Site logo

drone-plugins / drone-slack-blame Goto Github PK

View Code? Open in Web Editor NEW
22.0 7.0 16.0 957 KB

Drone plugin to send build status blames via Slack

Home Page: http://plugins.drone.io/drone-plugins/drone-slack-blame

License: Apache License 2.0

Go 100.00%
drone drone-plugin

drone-slack-blame's Introduction

drone-slack-blame

Build Status Gitter chat Join the discussion at https://discourse.drone.io Drone questions at https://stackoverflow.com Go Doc Go Report

Drone plugin to send build status blames via Slack. For the usage information and a listing of the available options please take a look at the docs.

Build

Build the binary with the following command:

export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on

go build -v -a -tags netgo -o release/linux/amd64/drone-slack-blame

Docker

Build the Docker image with the following command:

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/Dockerfile.linux.amd64 --tag plugins/slack-blame .

Usage

docker run --rm \
  -e PLUGIN_TOKEN=xxxxx \
  -e PLUGIN_CHANNEL=dev \
  -e PLUGIN_SUCCESS_USERNAME="Happy Keanu (on behalf of Drone)" \
  -e PLUGIN_SUCCESS_ICON=":happy_keanu:" \
  -e PLUGIN_SUCCESS_MESSAGE="The build is fixed!" \
  -e PLUGIN_SUCCESS_IMAGE_ATTACHMENTS="http://i.imgur.com/TP4PIxc.jpg" \
  -e PLUGIN_FAILURE_USERNAME="Sad Keanu (on behalf of Drone)" \
  -e PLUGIN_FAILURE_ICON=":sad_keanu:" \
  -e PLUGIN_FAILURE_MESSAGE="The build is broken!" \
  -e PLUGIN_FAILURE_IMAGE_ATTACHMENTS="http://cdn.meme.am/instances/51000361.jpg" \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  plugins/slack-blame

drone-slack-blame's People

Contributors

appleboy avatar bradrydzewski avatar donny-dont avatar henribru avatar jackspirou avatar josmo avatar kzaitsev avatar renovate-bot avatar rhiaxion avatar tboerger avatar techknowlogick avatar tonglil avatar

Stargazers

 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  avatar  avatar  avatar

drone-slack-blame's Issues

slack name not retrieving current name of user

The bot is currently trying to tag users by their old handles (likely first handles). An alternative could also be tagging users by their user Ids, and whatever name is picked up to ensure they're always tagged.

IIRC, the syntax bot users can use to tag users is the following:

<@{slackUserId}|{slackUsername}>

Always sends success

I have the following step

- name: Notify author of result
  image: plugins/slack-blame
  settings:
    failure_template: "failure"
    mapping: /drone/src/ci/common/drone/slack-github-user-mapping.json
    success_template: "success"
    token: xxx
  when:
    status:
    - failure
  depends_on:
  - Parse Slack usernames
  - Check code formatting
  - Run SonarQube scanner

When one of steps in depends_on fails Slack plugin detects failure in when and runs - that is correct.
However the status sent into message is wrong - success - see the message in Slack:

Build succeeded
success

S3/JSON Name Lookup Support

@donny-dont I'm opening this as a way to have a start point to work out my PR to the drone-slack plugin (drone-plugins/drone-slack#84)

I have a few questions before I migrate that work over to this project.

Would a PR for S3 support be welcome? Rather than define a user map string in my drone.yml file I would rather use a mapping that already exists for my team which lives on S3. I believe in using a single source of truth as much as possible.

For my team, that mapping file is formatted in JSON. Would that be a welcome option for the user mapping here? Not to replace what already exists but just a second accepted format?

Message on build status change

It'd be nice to send messages when the build status changes, i.e. not sending it for any successful builds but only for the ones that changed it to success after a failing status.

allow storing a github -> slack user mapping

the majority of my team doesn't have matching emails in github and slack, so it would be nice if we could manually map those.

ideally this would be in the secrets somehow, could just be a simple github_user=slack_user,github_user2=slack_user2 list which would be easy-ish to put in secrets and expand in the plugin

Prefix the channel automatically

If you add a # prefix automatically you don't need to quote the channel. I have created a pull request for something similar to drone-irc and drone-slack :)

slack.name empty

screen shot 2018-10-02 at 09 45 36

This happens for both github and gitlab repos.

.drone.yml is copy/pasted from the docs:

  slack_blame:
    image: plugins/slack-blame
    secrets: [ slack_token ]
    channel: paxdb-build-bot
    success_template: |
       build is green :) Thanks @{{slack.name}}
    failure_template: |
       build is broken :( Blame {{slack.name}}
    when:
        status: [ failure, success ]

For the gitlab build the emails for gitlab and slack are identical, but for github they are different, so that shouldn't be a reason?

drone runs in docker containers:

  • drone/agent sha256:972f5ed363b0dbff8f13b79d787570a3cd5c35cd2d294ab2c4ec0c779d4e074e
  • plugins/slack-blame sha256:7cc14b048edddd4b4b68a026750e4d8c48678af9aaded55addb559d48c5e9bb8

allow variables in messages

might be nice to expand $$VARIABLE style variables in messages, that would allow for super customizable alerts that show as much or as little information as an end user wants

Allow message formatting

Per Slack's documentation, message text in attachments isn't formatted by default. It would be great to enable it by setting the mrkdwn_in array to ["pretext", "text", "fields"].

Looks like a straight-forward enough change. I might even be able to submit a PR for it tomorrow.

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.