ci_slack 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ci_slack/configuration.rb +13 -11
- data/lib/ci_slack/messager.rb +24 -22
- data/lib/ci_slack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dd6080849e524768a895b23a0de8e9cef4aba5c
|
4
|
+
data.tar.gz: 2cb3a574cc6ccf1a6bcc1cc78d45b91e4ca30381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d770339dfaf4d44be06b5c7fd8020ed58124ea1dd8e9169df8a2f09f335ceae686ca95f8b032b67be551f51fa88cd7e8ba726ea67ab497f4506069a38e49e5cb
|
7
|
+
data.tar.gz: 60f3659efadefea3dd298eb800492e57799b3fecebb80d1448fdd3064a828dade54df0acb87d82873856a69abc80581b89b4e2667ef59fa35b32d747200fb209
|
@@ -1,14 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module CiSlack
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :icon, :webhook, :channel, :ci_computer,
|
4
|
+
:bot_name, :project, :slack_names
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
def initialize
|
7
|
+
@icon = 'failed'
|
8
|
+
@webhook = ''
|
9
|
+
@channel = '#ci'
|
10
|
+
@bot_name = 'CI BOT'
|
11
|
+
@project = ''
|
12
|
+
@slack_names = {}
|
13
|
+
@ci_computer = 'CI'
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
data/lib/ci_slack/messager.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
require 'slack-notifier'
|
2
2
|
require 'ci_slack'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module CiSlack
|
5
|
+
class Messager
|
6
|
+
attr_reader :client, :project
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def initialize
|
9
|
+
@client = ::Slack::Notifier.new(webhook, channel: channel, username: bot_name)
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
def send(message)
|
13
|
+
return unless ENV[ci_computer.to_s]
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
author, commit_message = last_git_log
|
16
|
+
slack_name = slack_names.select { |key, _| author.downcase =~ key }.values.first || author
|
16
17
|
|
17
|
-
|
18
|
+
text = "#{ project }. CI FAILED!\n<@#{ slack_name }> : #{ commit_message } \n#{ message }"
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
client.post(text: text, icon_emoji: ":#{ icon }:")
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def method_missing(method, *args)
|
24
|
+
if %i[icon webhook channel ci_computer
|
25
|
+
bot_name project slack_names].include?(method)
|
26
|
+
CiSlack.configuration.send(method)
|
27
|
+
else
|
28
|
+
super
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
30
31
|
|
31
|
-
|
32
|
+
private
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
def last_git_log
|
35
|
+
`git log -1 --pretty='%an||%s'`.split('||').map(&:strip)
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/ci_slack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- skrinits
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-notifier
|