lita-gitlab-ci 0.0.1
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 +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +24 -0
- data/Rakefile +6 -0
- data/lib/lita-gitlab-ci.rb +7 -0
- data/lib/lita/handlers/gitlab_ci.rb +42 -0
- data/lita-gitlab-ci.gemspec +25 -0
- data/locales/en.yml +4 -0
- data/spec/fixtures/webhook.json +49 -0
- data/spec/lita/handlers/gitlab_ci_spec.rb +35 -0
- data/spec/spec_helper.rb +18 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c378fabd98e95587dc3584b652a6696f5fed8798
|
4
|
+
data.tar.gz: 304643f45c3402b40b34993774c658b13cf35c9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 856fbd811007e37c539913eedbca20ac46b19d73f0753ccb18374ee53c173bc604d763b3b71f84db0efca399adfc548e48994a06580f9615d32ed1e9a74cf7d6
|
7
|
+
data.tar.gz: 4ede8ec62e914de8e64a034fdf39b80a577cb82785d9a96b32c01bae27e4f594d504ab6db1b3db00b309a12488b83e3a9547c608727d3cc8f13aa6cf6b385b17
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 蒼時弦也
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# lita-gitlab-ci
|
2
|
+
|
3
|
+
TODO: Add a description of the plugin.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-gitlab-ci to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-gitlab-ci"
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
## Configuration
|
15
|
+
|
16
|
+
TODO: Describe any configuration attributes the plugin exposes.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
TODO: Describe the plugin's features and how to use them.
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class GitlabCi < Handler
|
4
|
+
|
5
|
+
def self.default_config(config)
|
6
|
+
config.rooms = %w(#general)
|
7
|
+
end
|
8
|
+
|
9
|
+
http.post '/lita/gitlab-ci', :webhook
|
10
|
+
|
11
|
+
def webhook(request, response)
|
12
|
+
data = parse_json(request.body)
|
13
|
+
|
14
|
+
# Build Information
|
15
|
+
project_name = data["project_name"]
|
16
|
+
build_status = data["build_status"]
|
17
|
+
build_date = Time.parse(data["build_started_at"]) # UTC Time
|
18
|
+
branch = data["ref"]
|
19
|
+
|
20
|
+
message_body = "#{project_name} (#{branch}) build on #{build_date} and #{build_status}."
|
21
|
+
|
22
|
+
rooms = Lita.config.handlers.gitlab_ci.rooms
|
23
|
+
rooms.each do |room|
|
24
|
+
target = Source.new(room: room)
|
25
|
+
robot.send_message(target, message_body)
|
26
|
+
end
|
27
|
+
|
28
|
+
response.body << message_body
|
29
|
+
end
|
30
|
+
private
|
31
|
+
|
32
|
+
def parse_json(json_data)
|
33
|
+
MultiJson.load(json_data)
|
34
|
+
rescue MultiJson::LoadError => e
|
35
|
+
Lita.logger.error("Could not parse JSON data from Gitlab CI: #{e.message}")
|
36
|
+
return
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Lita.register_handler(GitlabCi)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-gitlab-ci"
|
3
|
+
spec.version = "0.0.1"
|
4
|
+
spec.authors = ["蒼時弦也"]
|
5
|
+
spec.email = ["elct9620@frost.tw"]
|
6
|
+
spec.description = %q{Lita Gitlab handler for send message about build status.}
|
7
|
+
spec.summary = %q{Lita Gitlab handler for send message about build status.}
|
8
|
+
spec.homepage = "https://github.com/elct9620/lita-gitlab-ci"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 3.3"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
22
|
+
spec.add_development_dependency "shoulda", ">= 3.5.0"
|
23
|
+
spec.add_development_dependency "simplecov"
|
24
|
+
spec.add_development_dependency "coveralls"
|
25
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"build_id": 2,
|
3
|
+
"build_status": "failed",
|
4
|
+
"build_started_at": "2014-05-05T18:01:02.563Z",
|
5
|
+
"build_finished_at": "2014-05-05T18:01:07.611Z",
|
6
|
+
"project_id": 1,
|
7
|
+
"project_name": "Brightbox \/ Brightbox Cli",
|
8
|
+
"gitlab_url": "http:\/\/localhost:3000\/brightbox\/brightbox-cli",
|
9
|
+
"ref": "master",
|
10
|
+
"sha": "a26cf5de9ed9827746d4970872376b10d9325f40",
|
11
|
+
"before_sha": "34f57f6ba3ed0c21c5e361bbb041c3591411176c",
|
12
|
+
"push_data": {
|
13
|
+
"before": "34f57f6ba3ed0c21c5e361bbb041c3591411176c",
|
14
|
+
"after": "a26cf5de9ed9827746d4970872376b10d9325f40",
|
15
|
+
"ref": "refs\/heads\/master",
|
16
|
+
"user_id": 1,
|
17
|
+
"user_name": "Administrator",
|
18
|
+
"project_id": 5,
|
19
|
+
"repository": {
|
20
|
+
"name": "Brightbox Cli",
|
21
|
+
"url": "dzaporozhets@localhost:brightbox\/brightbox-cli.git",
|
22
|
+
"description": "Voluptatibus quae error consectetur voluptas dolores vel excepturi possimus.",
|
23
|
+
"homepage": "http:\/\/localhost:3000\/brightbox\/brightbox-cli"
|
24
|
+
},
|
25
|
+
"commits": [
|
26
|
+
{
|
27
|
+
"id": "a26cf5de9ed9827746d4970872376b10d9325f40",
|
28
|
+
"message": "Release v1.2.2",
|
29
|
+
"timestamp": "2014-04-22T16:46:42+03:00",
|
30
|
+
"url": "http:\/\/localhost:3000\/brightbox\/brightbox-cli\/commit\/a26cf5de9ed9827746d4970872376b10d9325f40",
|
31
|
+
"author": {
|
32
|
+
"name": "Paul Thornthwaite",
|
33
|
+
"email": "tokengeek@gmail.com"
|
34
|
+
}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"id": "34f57f6ba3ed0c21c5e361bbb041c3591411176c",
|
38
|
+
"message": "Fix server user data update\n\nIncorrect condition was being used so Base64 encoding option was having\nopposite effect from desired.",
|
39
|
+
"timestamp": "2014-04-11T18:17:26+03:00",
|
40
|
+
"url": "http:\/\/localhost:3000\/brightbox\/brightbox-cli\/commit\/34f57f6ba3ed0c21c5e361bbb041c3591411176c",
|
41
|
+
"author": {
|
42
|
+
"name": "Paul Thornthwaite",
|
43
|
+
"email": "tokengeek@gmail.com"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
],
|
47
|
+
"total_commits_count": 2
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::GitlabCi, lita_handler: true do
|
4
|
+
|
5
|
+
http_route_path = '/lita/gitlab-ci'
|
6
|
+
|
7
|
+
it "registers with Lita" do
|
8
|
+
expect(Lita.handlers).to include(described_class)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "registers HTTP route POST #{http_route_path} to :webhook" do
|
12
|
+
routes_http(:post, http_route_path).to(:webhook)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:request) { double('Rack::Request') }
|
16
|
+
let(:response) { Rack::Response.new }
|
17
|
+
|
18
|
+
describe "#webhook" do
|
19
|
+
let(:webhook_data) { fixture_file('webhook') }
|
20
|
+
let(:build_message) { "Brightbox / Brightbox Cli (master) build on 2014-05-05 18:01:02 UTC and failed." }
|
21
|
+
before do
|
22
|
+
allow(request).to receive(:body).and_return(webhook_data)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should notifies user to new build status" do
|
26
|
+
expect(robot).to receive(:send_message) do |target, message|
|
27
|
+
expect(message).to eq build_message
|
28
|
+
end
|
29
|
+
|
30
|
+
subject.webhook(request, response)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
require "coveralls"
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start { add_filter "/spec/" }
|
8
|
+
|
9
|
+
require "lita-gitlab-ci"
|
10
|
+
require "lita/rspec"
|
11
|
+
|
12
|
+
# From lita-gitlab
|
13
|
+
# File: https://github.com/milo-ft/lita-gitlab/blob/master/spec%2Fspec_helper.rb
|
14
|
+
def fixture_file(filename)
|
15
|
+
return '' if filename == ''
|
16
|
+
file_path = File.expand_path("#{File.dirname(__FILE__)}/fixtures/#{filename}.json")
|
17
|
+
File.read(file_path)
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-gitlab-ci
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 蒼時弦也
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: shoulda
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.5.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.5.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Lita Gitlab handler for send message about build status.
|
112
|
+
email:
|
113
|
+
- elct9620@frost.tw
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .travis.yml
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/lita-gitlab-ci.rb
|
125
|
+
- lib/lita/handlers/gitlab_ci.rb
|
126
|
+
- lita-gitlab-ci.gemspec
|
127
|
+
- locales/en.yml
|
128
|
+
- spec/fixtures/webhook.json
|
129
|
+
- spec/lita/handlers/gitlab_ci_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: https://github.com/elct9620/lita-gitlab-ci
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata:
|
135
|
+
lita_plugin_type: handler
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.2.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Lita Gitlab handler for send message about build status.
|
156
|
+
test_files:
|
157
|
+
- spec/fixtures/webhook.json
|
158
|
+
- spec/lita/handlers/gitlab_ci_spec.rb
|
159
|
+
- spec/spec_helper.rb
|