janky-slack-custom 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +79 -0
- data/README.md +33 -0
- data/janky-slack-custom.gemspec +21 -0
- data/lib/janky/chat_service/slack_custom.rb +67 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0365240d53b649541e9adbf4873091be7c6bb8fb
|
4
|
+
data.tar.gz: 42df3bc34ca09f4ee645b3d64029428b3f6fcc42
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b17e870b0052583cb96b0c34ffc8546825f006a36adccc4ddafb79bddb978b5edb667691b52246e17ad9af0c49c340e1159bbd5b865d7000b9b28de98e75cc92
|
7
|
+
data.tar.gz: a40554606643695241a408e704b7586eedaeb452ccbc3025774dff0a26fb38f1ddbe58a7a6cadb57a2e44e71890e9890920468f6a6929a96e7e2e41d691c4bd0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
janky-slack-custom (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.2.22.2)
|
10
|
+
activesupport (= 3.2.22.2)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
activerecord (3.2.22.2)
|
13
|
+
activemodel (= 3.2.22.2)
|
14
|
+
activesupport (= 3.2.22.2)
|
15
|
+
arel (~> 3.0.2)
|
16
|
+
tzinfo (~> 0.3.29)
|
17
|
+
activesupport (3.2.22.2)
|
18
|
+
i18n (~> 0.6, >= 0.6.4)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
addressable (2.4.0)
|
21
|
+
arel (3.0.3)
|
22
|
+
broach (0.3.0)
|
23
|
+
multi_json (~> 1.7)
|
24
|
+
nap (~> 0.5)
|
25
|
+
builder (3.0.4)
|
26
|
+
faraday (0.9.2)
|
27
|
+
multipart-post (>= 1.2, < 3)
|
28
|
+
i18n (0.7.0)
|
29
|
+
janky (0.10.2)
|
30
|
+
activerecord (~> 3.2.0)
|
31
|
+
broach (~> 0.2)
|
32
|
+
mustache (~> 0.11)
|
33
|
+
rake (~> 0.9.2)
|
34
|
+
replicate (~> 1.4)
|
35
|
+
sinatra (~> 1.3)
|
36
|
+
sinatra_auth_github (~> 1.0.0)
|
37
|
+
yajl-ruby (~> 1.1.0)
|
38
|
+
multi_json (1.11.2)
|
39
|
+
multipart-post (2.0.0)
|
40
|
+
mustache (0.99.8)
|
41
|
+
nap (0.8.0)
|
42
|
+
octokit (4.3.0)
|
43
|
+
sawyer (~> 0.7.0, >= 0.5.3)
|
44
|
+
rack (1.6.4)
|
45
|
+
rack-protection (1.5.3)
|
46
|
+
rack
|
47
|
+
rake (0.9.6)
|
48
|
+
replicate (1.5.1)
|
49
|
+
sawyer (0.7.0)
|
50
|
+
addressable (>= 2.3.5, < 2.5)
|
51
|
+
faraday (~> 0.8, < 0.10)
|
52
|
+
sinatra (1.4.7)
|
53
|
+
rack (~> 1.5)
|
54
|
+
rack-protection (~> 1.4)
|
55
|
+
tilt (>= 1.3, < 3)
|
56
|
+
sinatra_auth_github (1.0.0)
|
57
|
+
sinatra (~> 1.0)
|
58
|
+
warden-github (~> 1.0)
|
59
|
+
tilt (2.0.2)
|
60
|
+
tzinfo (0.3.47)
|
61
|
+
warden (1.2.6)
|
62
|
+
rack (>= 1.0)
|
63
|
+
warden-github (1.2.0)
|
64
|
+
activesupport (> 3.0)
|
65
|
+
octokit (> 2.1.0)
|
66
|
+
warden (> 1.0)
|
67
|
+
yajl-ruby (1.1.0)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bundler (~> 1.6)
|
74
|
+
janky (~> 0)
|
75
|
+
janky-slack-custom!
|
76
|
+
rake (~> 0)
|
77
|
+
|
78
|
+
BUNDLED WITH
|
79
|
+
1.11.2
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# janky-slack
|
2
|
+
|
3
|
+
[Slack](https://slack.com/) chat service adapter for
|
4
|
+
[Janky](https://github.com/github/janky).
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
* Add `gem "janky-slack-custom", "~>0.1"` to your `Gemfile`
|
8
|
+
* Run `bundle` to update the `Gemfile.lock`
|
9
|
+
* Add `require "janky/chat_service/slack"` before `Janky.setup(ENV)` in
|
10
|
+
`config/environment.rb`
|
11
|
+
* Commit the changes and deploy to Heroku
|
12
|
+
* Run `heroku run rake db:migrate` to migrate the database
|
13
|
+
|
14
|
+
## Configuration
|
15
|
+
|
16
|
+
You will need to setup an incoming webhook integration for your Slack team. You
|
17
|
+
can set this up at https://slack.com/services/new/incoming-webhook. When you
|
18
|
+
have created the incoming webhook take note of the `token` value in the URL for
|
19
|
+
the webhook.
|
20
|
+
* `JANKY_CHAT` set to `slackcustom`
|
21
|
+
* `JANKY_CHAT_DEFAULT_ROOM` set to the default Slack channel (includes the #)
|
22
|
+
* `JANKY_CHAT_SLACKCUSTOM_ACCOUNT` set to your Slack team name
|
23
|
+
* `JANKY_CHAT_SLACKCUSTOM_TOKEN` set to your authentication token found at
|
24
|
+
https://api.slack.com
|
25
|
+
* `JANKY_CHAT_SLACKCUSTOM_HOOK_TOKEN` set to your incoming webhook token from
|
26
|
+
earlier
|
27
|
+
Once these are all configured you're ready to have your build notifications
|
28
|
+
come into your Slack channels. If you want to customise the username and icon
|
29
|
+
that the Slack reports display, you can set the following environment
|
30
|
+
variables:
|
31
|
+
* `JANKY_CHAT_SLACKCUSTOM_USERNAME` is the username to report as (default: `hubot`)
|
32
|
+
* `JANKY_CHAT_SLACKCUSTOM_ICON_URL` is the icon to display (default: [labtocat][])
|
33
|
+
[labtocat]: https://octodex.github.com/images/labtocat.png
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'janky-slack-custom'
|
6
|
+
spec.version = '0.1.0'
|
7
|
+
spec.authors = ['Jose Luis Salas']
|
8
|
+
spec.email = ['joseluis@flywire.com']
|
9
|
+
spec.summary = 'Custom slack chat service adapter for Janky.'
|
10
|
+
spec.description = 'Send Janky build notifications to your Slack rooms.'
|
11
|
+
spec.homepage = 'http://github.com/peertransfer/janky-slack-custom'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
19
|
+
spec.add_development_dependency 'rake', '~> 0'
|
20
|
+
spec.add_development_dependency 'janky', '~> 0'
|
21
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "slack"
|
2
|
+
|
3
|
+
module Janky
|
4
|
+
module ChatService
|
5
|
+
class SlackCustom
|
6
|
+
def initialize(settings)
|
7
|
+
team = settings["JANKY_CHAT_SLACKCUSTOM_TEAM"]
|
8
|
+
|
9
|
+
puts settings.inspect
|
10
|
+
if team.nil? || team.empty?
|
11
|
+
raise Error, "JANKY_CHAT_SLACKCUSTOM_TEAM setting is required"
|
12
|
+
end
|
13
|
+
|
14
|
+
token = settings["JANKY_CHAT_SLACKCUSTOM_TOKEN"]
|
15
|
+
|
16
|
+
if token.nil? || token.empty?
|
17
|
+
raise Error, "JANKY_CHAT_SLACKCUSTOM_TOKEN setting is required"
|
18
|
+
end
|
19
|
+
|
20
|
+
username = settings["JANKY_CHAT_SLACKCUSTOM_USERNAME"] || 'CI'
|
21
|
+
icon_url = settings["JANKY_CHAT_SLACKCUSTOM_ICON_URL"]
|
22
|
+
|
23
|
+
@client = ::Slack::Client.new(team: team, token: token, username: username, icon_url: icon_url)
|
24
|
+
end
|
25
|
+
|
26
|
+
def speak(message, room_id, options = {})
|
27
|
+
room_name = ChatService.room_name(room_id) || room_id
|
28
|
+
|
29
|
+
if options[:build].present?
|
30
|
+
@client.post_message(nil, room_name, {attachments: attachments(message, options[:build])})
|
31
|
+
else
|
32
|
+
@client.post_message(message, room_name, options)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def rooms
|
37
|
+
@rooms ||= @client.channels.map do |channel|
|
38
|
+
Room.new(channel['id'], channel['name'])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def attachments(fallback, build)
|
45
|
+
status = build.green? ? "was successful" : "failed"
|
46
|
+
color = build.green? ? "good" : "danger"
|
47
|
+
|
48
|
+
message = "Build #%s of %s/%s %s" % [
|
49
|
+
build.number,
|
50
|
+
build.repo_name,
|
51
|
+
build.branch_name,
|
52
|
+
status
|
53
|
+
]
|
54
|
+
|
55
|
+
janky_field = ::Slack::AttachmentField.new("Janky", build.web_url, false)
|
56
|
+
commit_field = ::Slack::AttachmentField.new("Commit", "<#{build.commit_url}|#{build.short_sha1}>", true)
|
57
|
+
duration_field = ::Slack::AttachmentField.new("Duration", "#{build.duration}s", true)
|
58
|
+
user_field = ::Slack::AttachmentField.new("User", "#{build.user}", true)
|
59
|
+
fields = [janky_field.to_h, commit_field.to_h, duration_field.to_h, user_field]
|
60
|
+
|
61
|
+
[::Slack::Attachment.new(fallback, message, nil, color, ["text", "title", "fallback"], fields)]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
register_chat_service "slackcustom", ChatService::SlackCustom
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: janky-slack-custom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jose Luis Salas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: janky
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Send Janky build notifications to your Slack rooms.
|
56
|
+
email:
|
57
|
+
- joseluis@flywire.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- README.md
|
66
|
+
- janky-slack-custom.gemspec
|
67
|
+
- lib/janky/chat_service/slack_custom.rb
|
68
|
+
homepage: http://github.com/peertransfer/janky-slack-custom
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.5
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Custom slack chat service adapter for Janky.
|
92
|
+
test_files: []
|