github_status_notifier 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/github_status_notifier/cli.rb +1 -1
- data/lib/github_status_notifier/notifier.rb +30 -1
- data/lib/github_status_notifier/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0fc8a546451c9fe69cc6fd17d98a21a5ee9e0ed
|
4
|
+
data.tar.gz: d026f96c690d4633eba50be50410e9e5999e794b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 231c867ad4f0f81116a665ed5185345eec1f3d210a7ccf650c932924dc045a2cae9f818760704f605174b24a82ee3d86e998f6e88967351116df51513d767c9f
|
7
|
+
data.tar.gz: d7b7af9cd8e888ff66b399e571a62409552fab768cc6bf239688386ff36350f343569d7196321b82c66131265f4cae554d605cd4dad1446cfbd2341a95c2a337
|
data/README.md
CHANGED
@@ -15,6 +15,8 @@ $ SOME_YOUR_COMMAND
|
|
15
15
|
$ github-status-notifier notify --exit-status $?
|
16
16
|
```
|
17
17
|
|
18
|
+
![GitHub Status](https://cloud.githubusercontent.com/assets/75448/6426125/d4bd4bb8-bf8c-11e4-829e-79b02bb7d6f2.png)
|
19
|
+
|
18
20
|
## Commands
|
19
21
|
|
20
22
|
```
|
@@ -32,6 +34,7 @@ Options:
|
|
32
34
|
[--debug], [--no-debug]
|
33
35
|
[--verbose], [--no-verbose]
|
34
36
|
[--state=STATE]
|
37
|
+
# Possible values: pending, success, error, failure
|
35
38
|
[--target-url=TARGET_URL]
|
36
39
|
[--description=DESCRIPTION]
|
37
40
|
[--context=CONTEXT]
|
@@ -18,7 +18,7 @@ module GithubStatusNotifier
|
|
18
18
|
option :keep_exit_status, type: :boolean, default: false
|
19
19
|
option :debug, type: :boolean, default: false
|
20
20
|
option :verbose, type: :boolean, default: false
|
21
|
-
option :state, type: :string
|
21
|
+
option :state, type: :string, enum: %w(pending success error failure)
|
22
22
|
option :target_url, type: :string
|
23
23
|
option :description, type: :string
|
24
24
|
option :context, type: :string
|
@@ -13,7 +13,7 @@ module GithubStatusNotifier
|
|
13
13
|
repo = Repository.new(repo_path)
|
14
14
|
client = Client.new(repo)
|
15
15
|
pass_params = {
|
16
|
-
target_url: params[:target_url],
|
16
|
+
target_url: decide_target_url(params[:target_url]),
|
17
17
|
description: params[:description],
|
18
18
|
context: decide_context(params[:context])
|
19
19
|
}
|
@@ -23,6 +23,35 @@ module GithubStatusNotifier
|
|
23
23
|
logger.error e.backtrace
|
24
24
|
end
|
25
25
|
|
26
|
+
def decide_target_url(url)
|
27
|
+
url || env_target_url
|
28
|
+
end
|
29
|
+
|
30
|
+
def env_target_url
|
31
|
+
if ENV['TARGET_URL']
|
32
|
+
ENV['TARGET_URL']
|
33
|
+
elsif ENV['TRAVIS']
|
34
|
+
build_travis_target_url
|
35
|
+
elsif ENV['CIRCLECI']
|
36
|
+
build_circle_target_url
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def build_circle_target_url
|
41
|
+
host = ENV['CIRCLE_HOST'] || 'circleci.com'
|
42
|
+
link = ENV['CIRCLE_LINK'] || 'gh'
|
43
|
+
slug = ENV['CIRCLE_PROJECT_USERNAME'] + '/' + ENV['CIRCLE_PROJECT_REPONAME']
|
44
|
+
job_id = ENV['CIRCLE_BUILD_NUM']
|
45
|
+
"https://#{host}/#{link}/#{slug}/#{job_id}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def build_travis_target_url
|
49
|
+
host = ENV['TRAVIS_HOST'] || 'travis-ci.org'
|
50
|
+
slug = ENV['TRAVIS_REPO_SLUG']
|
51
|
+
job_id = ENV['TRAVIS_JOB_ID']
|
52
|
+
"https://#{host}/#{slug}/jobs/#{job_id}"
|
53
|
+
end
|
54
|
+
|
26
55
|
def decide_context(text)
|
27
56
|
text || CONTEXT
|
28
57
|
end
|