gocd 1.3 → 1.3.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 +19 -2
- data/lib/gocd/pipeline_status/pipeline.rb +6 -2
- data/lib/gocd/version.rb +1 -1
- data/spec/gocd/pipeline_status/pipeline_spec.rb +43 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6851fe731d257a4bfb632948329e79ae9e8b27a2960927d39410981c66adcc75
|
4
|
+
data.tar.gz: e7a0e79d7bff7f26ec9dcc9eb3097ebf761b508bdb156e54d6480c6764f966bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36e2c47c1215848ac9ce64fe1255a491d50060bca9dbd84e065040952bcef117fed28b03defb23430d1c5a54fe265c3fc7072546d4bb688bdda0c28c9ad13ba4
|
7
|
+
data.tar.gz: e9e6fe0155880227c3a78862c7f3267ad1e3182ff25af21700616c463f20ee33d285f5f74f7af020e3536242e8e15ca4817828cf34d3c1464eb346020f7135ed
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ gem install gocd
|
|
20
20
|
```
|
21
21
|
|
22
22
|
### Code Documentation
|
23
|
-
http://www.rubydoc.info/gems/gocd/1.
|
23
|
+
http://www.rubydoc.info/gems/gocd/1.3
|
24
24
|
|
25
25
|
### Usage
|
26
26
|
|
@@ -43,6 +43,23 @@ pipelines.status
|
|
43
43
|
pipelines.any_red?
|
44
44
|
```
|
45
45
|
|
46
|
+
#### Cache
|
47
|
+
By default all methods in ```GOCD::AllPipelines``` and ```GOCD::PipelineGroup``` make a call to go api to fetch the latest status of pipelines. This can be avoided using cache. To enable cache just pass ```cache: true``` when you call any of the method in ```GOCD::AllPipelines``` and ```GOCD::PipelineGroup```.
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
GOCD::AllPipelines.any_red?(cache: true)
|
51
|
+
GOCD::AllPipelines.red_pipelines(cache: true)
|
52
|
+
GOCD::AllPipelines.green_pipelines(cache: true)
|
53
|
+
GOCD::AllPipelines.status(cache: true)
|
54
|
+
```
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
pipelines = GOCD::PipelineGroup.new(['Pipeline1 :: stage1'], cache: true)
|
58
|
+
pipelines.red_pipelines # will return red pipelines from cache
|
59
|
+
pipelines.status # will return pipelines status from cache
|
60
|
+
pipelines.any_red?(cache: false) # will check with the latest pipelines
|
61
|
+
```
|
62
|
+
|
46
63
|
#### Want to create your own gocd dashboard? Its easy now!
|
47
64
|
```ruby
|
48
65
|
require 'sinatra'
|
@@ -51,7 +68,7 @@ require 'gocd'
|
|
51
68
|
get '/' do
|
52
69
|
GOCD.server = GOCD::Server.new 'http://goserverurl.com'
|
53
70
|
GOCD.credentials = GOCD::Credentials.new 'username', 'password'
|
54
|
-
GOCD::AllPipelines.red_pipelines.map {|pipeline| pipeline.to_hash}.to_json
|
71
|
+
GOCD::AllPipelines.red_pipelines(cache: false).map {|pipeline| pipeline.to_hash}.to_json
|
55
72
|
end
|
56
73
|
```
|
57
74
|
|
@@ -13,7 +13,7 @@ module GOCD
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def status
|
16
|
-
{pipeline: name, status:
|
16
|
+
{pipeline: name, status: current_status}
|
17
17
|
end
|
18
18
|
|
19
19
|
def red?
|
@@ -39,5 +39,9 @@ module GOCD
|
|
39
39
|
def to_hash
|
40
40
|
@pipeline
|
41
41
|
end
|
42
|
+
|
43
|
+
def current_status
|
44
|
+
(@pipeline['activity'] && @pipeline['activity'].downcase == 'sleeping') ? last_build_status : @pipeline['activity']
|
45
|
+
end
|
42
46
|
end
|
43
|
-
end
|
47
|
+
end
|
data/lib/gocd/version.rb
CHANGED
@@ -12,6 +12,11 @@ RSpec.describe GOCD::Pipeline, 'pipeline' do
|
|
12
12
|
expect(@pipeline.name).to eq 'pipeline 1'
|
13
13
|
end
|
14
14
|
|
15
|
+
it '#status should be success' do
|
16
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
17
|
+
expect(@pipeline.status).to eq({pipeline: 'pipeline 1', status: 'Success'})
|
18
|
+
end
|
19
|
+
|
15
20
|
it '#last_build_status should return last build status' do
|
16
21
|
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
17
22
|
expect(@pipeline.last_build_status).to eq 'Success'
|
@@ -33,6 +38,11 @@ RSpec.describe GOCD::Pipeline, 'pipeline' do
|
|
33
38
|
@raw_pipeline = {'name' => 'pipeline 1', 'activity' => 'sleeping', 'lastBuildStatus' => 'Failure'}
|
34
39
|
end
|
35
40
|
|
41
|
+
it '#status should be failure' do
|
42
|
+
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
43
|
+
expect(@pipeline.status).to eq({pipeline: 'pipeline 1', status: 'Failure'})
|
44
|
+
end
|
45
|
+
|
36
46
|
it '#green? should return false' do
|
37
47
|
@pipeline = GOCD::Pipeline.new @raw_pipeline
|
38
48
|
expect(@pipeline.green?).to be_falsey
|
@@ -57,4 +67,36 @@ RSpec.describe GOCD::Pipeline, 'pipeline' do
|
|
57
67
|
expect(pipeline.last_build_label).to eq('lable')
|
58
68
|
expect(pipeline.to_hash).to eq(@raw_pipeline)
|
59
69
|
end
|
60
|
-
|
70
|
+
|
71
|
+
context 'when a previously successful pipeline is running' do
|
72
|
+
let(:raw_pipeline) { {'name' => 'pipeline 1', 'activity' => 'Building', 'lastBuildStatus' => 'Success'} }
|
73
|
+
|
74
|
+
it '#status should be building' do
|
75
|
+
expect(GOCD::Pipeline.new(raw_pipeline).status).to eq({pipeline: 'pipeline 1', status: 'Building'})
|
76
|
+
end
|
77
|
+
|
78
|
+
it '#green? should return true' do
|
79
|
+
expect(GOCD::Pipeline.new(raw_pipeline).green?).to be_truthy
|
80
|
+
end
|
81
|
+
|
82
|
+
it '#red? should return false' do
|
83
|
+
expect(GOCD::Pipeline.new(raw_pipeline).red?).to be_falsey
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when a previously failed pipeline is running' do
|
88
|
+
let(:raw_pipeline) { {'name' => 'pipeline 1', 'activity' => 'Building', 'lastBuildStatus' => 'Failure'} }
|
89
|
+
|
90
|
+
it '#status should be building' do
|
91
|
+
expect(GOCD::Pipeline.new(raw_pipeline).status).to eq({pipeline: 'pipeline 1', status: 'Building'})
|
92
|
+
end
|
93
|
+
|
94
|
+
it '#green? should return false' do
|
95
|
+
expect(GOCD::Pipeline.new(raw_pipeline).green?).to be_falsey
|
96
|
+
end
|
97
|
+
|
98
|
+
it '#red? should return true' do
|
99
|
+
expect(GOCD::Pipeline.new(raw_pipeline).red?).to be_truthy
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gocd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ajit Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|