Coder Social home page Coder Social logo

nazrhyn / gitlab-slack Goto Github PK

View Code? Open in Web Editor NEW
80.0 80.0 20.0 126 KB

A service that receives hook notifications from GitLab and posts information to an incoming webhook on Slack.

License: MIT License

Shell 3.61% JavaScript 96.39%
gitlab javascript node slack

gitlab-slack's People

Contributors

nazrhyn 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlab-slack's Issues

Support for pipeline events

Do you plan to listen for "Pipeline events"?

One thing I can see being useful is custom notifications on important events, such as master build failing, etc, where the Slack integration would do an @here to the channel.

Add label change tracking

Add label change tracking by keeping track of existing issue label state and monitoring the issues on update events.

  • Add configuration per project for labels of interest.
  • On start up...
    • Fetch each project's labels and cache.
    • Fetch each project's open issues and cache label information.
  • For modified issues, branch to another function...
    • Compare the label states.
    • Update the cache.
    • Send a Slack message with an attachment per label with "Added|Removed label_name".
  • For new or closed issues, update the cache accordingly.

Rephrase commit message to not imply ownership

Currently, the message is _num_ new commits by _user_. It should be changed to something more like _user_ pushed _num_ new commits to stop implying that the commits are all by that user, when they often aren't.

Unrecognized messages result in an exception

When unrecognized messages come in, an exception happens in slack.js when it tries to access body.__kind.title when there is no __kind property. I forgot to add it in the default case in handlers/index.js.

StatusCodeError: 500 - undefined

Hi!
I'm trying to use your project integrating gitlab with Slack, and I've receive a 500 error after trying to make a test webhook inside the Gitlab project /yourproject/hooks.
So, here is the trace I've found in the logfile:

[2016-07-15T11:48:23.218Z](DEBUG) xx.xx.xx.98 POST -- DATA: {"object_kind":"push","event_name":"push","before":"3ebffceb071611684f8143272febfe871ca69736","after":"ca1ef66dbb057f7689922919255b001bb5e3ee1b","ref":"refs/heads/development","checkout_sha":"ca1ef66dbb057f7689922919255b001bb5e3ee1b","message":null,"user_id":392556,................"git_http_url":"https://gitlab.com/xxxxx/ourproject.git","git_ssh_url":"[email protected]:xxxxx/ourproject.git","visibility_level":0}}
[2016-07-15T11:48:23.219Z](DEBUG) xx.xx.xx.98 POST -- PROCESS: Commit
[2016-07-15T11:48:24.184Z](ERROR) xx.xx.xx.98 POST -- GITLAB: -- StatusCodeError: 500 - undefined    at new StatusCodeError (/opt/gitlab-slack/node_modules/request-promise/lib/errors.js:26:15)
    at Request.RP$callback [as _callback] (/opt/gitlab-slack/node_modules/request-promise/lib/rp.js:68:32)
    at Request.self.callback (/opt/gitlab-slack/node_modules/request-promise/node_modules/request/request.js:187:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/opt/gitlab-slack/node_modules/request-promise/node_modules/request/request.js:1044:10)
    at Request.emit (events.js:95:17)
    at IncomingMessage.<anonymous> (/opt/gitlab-slack/node_modules/request-promise/node_modules/request/request.js:965:12)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickCallback (node.js:448:13)

Btw, I've checked that the simple request it has worked properly:
curl -X POST --data-urlencode 'payload={"channel": "#gitlab", "username": "webhookbot", "text": "This is posted to #gitlab and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/xxxxxxx

What we can do?
Best,

change cacheIssueLabels to be parallel

When I found the right hammer to write cacheProjectIssues, caching the issue labels looked like a nail. In the case of cacheIssueLabels, I know the entire range of issue IDs, so I can just send off all the requests at once using all and drop them into the right place in the array. Should speed up the initialization process.

add exponential backoff to label caching requests

When GitLab starts up, the API isn't immediately available, even though the service has started. If label caching is enabled, API connection failures should result in an exponential backoff sequence capped at some amount after which the service should simply fail.

Optionally, status information about the backoff should be posted to the default channel for the Slack webhook so that there's some notification of this happening.

improve new-branch output behavior

When a new branch is detected, examine the commit list (which is currently being discarded). If there are commits by the same user who pushed the branch that are most-recent and contiguous, preserve those, discard the rest and, in addition to the new branch notification, also push a commit notification with the altered commit list.

Add support for group milestones

Group milestones can be assigned to projects within that group. We will need to perform a lookup for milestone information in two possible locations.

don't notify for issues modified when in closed state

The modified webhook still fires when an issue is closed, but at that point, we're expecting that issue to be untracked as far as its labels go. Any label changes will probably fire as adds.

Check, during modify events, to make sure that the issue is actually still open.

Issues should be linked if they are mentioned in the commit

If an issue is mentioned in the commit anywhere after the first line, it won't be sent to Slack. A possible feature could be to detect issue mentions in the entire commit message, and then display them with their own label alongside of the commit for easy access.

change to a real logging framework

Stop futzing with logging and just switch to something like debug or winston. I know, I already was doing this and decided not to, but I can't remember why, at this point...

It's probably going to be winston, even though that one's more complicated, because I don't want to couple the log file name with the linux service definition or write some code to import the log file name from a JSON file into the service definition.

If anyone's reading this and has a better idea, I'm all ears ๐Ÿ‘.

Only report unique issue references in commit summary

The commit summary is just counting up all issue references. It should also apply a distinct to that list so that if an issue is reference for more than one line item, it won't be duplicated in the commit summary notification.

Uncaught Exception: Cannot read property 'statusCode' of undefined

UNCAUGHT EXCEPTION: TypeError: Cannot read property 'statusCode' of undefined
TypeError: Cannot read property 'statusCode' of undefined
    at processResponse (/opt/gitlab-slack/server.js:486:61)
    at Request._callback (/opt/gitlab-slack/server.js:155:5)
    at self.callback (/opt/gitlab-slack/node_modules/request/request.js:373:22)
    at Request.EventEmitter.emit (events.js:95:17)
    at Request.onRequestError (/opt/gitlab-slack/node_modules/request/request.js:971:8)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1547:9)
    at CleartextStream.EventEmitter.emit (events.js:95:17)
    at Socket.onerror (tls.js:1445:17)
    at Socket.EventEmitter.emit (events.js:117:20)

display milestone in issue notification

If the milestone is set, display it in the issue notification, somewhere.

This will require the milestone to be set during the creation rather than after it, as we're still ignoring updates in general, unless they qualify for the label change tracking.

adding new untracked label is notifying of a label change

Label Setup

First  (Untracked)
Second (Tracked)
Third  (Added, Untracked)

Issue

When an issue with an untracked label and a tracked label has a new untracked label added to it, it's erroneously notifying that the tracked label is added. Confirmation of ability to reproduce will be needed; this set of conditions is just being transcribed from the instance where this error was observed.

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.