subordinate 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +108 -0
- data/Rakefile +1 -0
- data/lib/subordinate/authentication.rb +22 -0
- data/lib/subordinate/client/build.rb +85 -0
- data/lib/subordinate/client/job.rb +89 -0
- data/lib/subordinate/client/system.rb +81 -0
- data/lib/subordinate/client.rb +46 -0
- data/lib/subordinate/configuration.rb +35 -0
- data/lib/subordinate/connection.rb +20 -0
- data/lib/subordinate/request.rb +33 -0
- data/lib/subordinate/version.rb +3 -0
- data/lib/subordinate.rb +19 -0
- data/spec/fixtures/authentications.yml.sample +6 -0
- data/spec/spec_helper.rb +43 -0
- data/spec/subordinate/client/build_spec.rb +118 -0
- data/spec/subordinate/client/job_spec.rb +171 -0
- data/spec/subordinate/client/system_spec.rb +125 -0
- data/spec/subordinate/client_spec.rb +28 -0
- data/subordinate.gemspec +33 -0
- metadata +272 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
auth = authentications = YAML::load(File.open(File.expand_path("../../../fixtures/authentications.yml", __FILE__)))
|
4
|
+
|
5
|
+
# Client Spec
|
6
|
+
describe Subordinate::Client do
|
7
|
+
before do
|
8
|
+
Subordinate.reset!
|
9
|
+
Subordinate.configure do |c|
|
10
|
+
c.subdomain = auth["subdomain"]
|
11
|
+
c.domain = auth["domain"]
|
12
|
+
c.port = auth["port"]
|
13
|
+
c.ssl = false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:subordinate) { Subordinate::Client.new(:username => auth["username"], :api_token => auth["token"]) }
|
17
|
+
|
18
|
+
describe "#build", :vcr do
|
19
|
+
let(:current_response) { subordinate.build(auth["job"], 1) }
|
20
|
+
|
21
|
+
it "returns the job response" do
|
22
|
+
current_response.should_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
context "methods" do
|
26
|
+
it "responds to .actions" do
|
27
|
+
current_response.should respond_to(:actions)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "responds to .artifacts" do
|
31
|
+
current_response.should respond_to(:artifacts)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "responds to .building" do
|
35
|
+
current_response.should respond_to(:building)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "responds to .description" do
|
39
|
+
current_response.should respond_to(:description)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "responds to .duration" do
|
43
|
+
current_response.should respond_to(:duration)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "responds to .estimatedDuration" do
|
47
|
+
current_response.should respond_to(:estimatedDuration)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "responds to .executor" do
|
51
|
+
current_response.should respond_to(:executor)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "responds to .fullDisplayName" do
|
55
|
+
current_response.should respond_to(:fullDisplayName)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "responds to .id" do
|
59
|
+
current_response.should respond_to(:id)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "responds to .keepLog" do
|
63
|
+
current_response.should respond_to(:keepLog)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "responds to .number" do
|
67
|
+
current_response.should respond_to(:number)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "responds to .result" do
|
71
|
+
current_response.should respond_to(:result)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "responds to .timestamp" do
|
75
|
+
current_response.should respond_to(:timestamp)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "responds to .url" do
|
79
|
+
current_response.should respond_to(:url)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "responds to .builtOn" do
|
83
|
+
current_response.should respond_to(:builtOn)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "responds to .changeSet" do
|
87
|
+
current_response.should respond_to(:changeSet)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "responds to .culprits" do
|
91
|
+
current_response.should respond_to(:culprits)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "#build_timestamp" do
|
97
|
+
it "returns the timestamp of the specified build" do
|
98
|
+
stub_request(:get, "#{subordinate.api_endpoint}/job/#{auth['job']}/1/buildTimestamp").
|
99
|
+
to_return(:status => 302, :body => "3/25/13 3:30 AM", :headers => {})
|
100
|
+
|
101
|
+
|
102
|
+
subordinate.build_timestamp(auth["job"], 1).should == "3/25/13 3:30 AM"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "returns the timestamp in the specified format" do
|
106
|
+
stub_request(:get, "#{subordinate.api_endpoint}/job/#{auth['job']}/1/buildTimestamp?format=yyyy/MM/dd").
|
107
|
+
to_return(:status => 302, :body => "2013/03/25", :headers => {})
|
108
|
+
|
109
|
+
subordinate.build_timestamp(auth["job"], 1, "yyyy/MM/dd").should == "2013/03/25"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#console_output_for_build", :vcr do
|
114
|
+
it "returns the console output for a complete build" do
|
115
|
+
subordinate.console_output_for_build(auth["job"], 1).should_not be_nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
auth = authentications = YAML::load(File.open(File.expand_path("../../../fixtures/authentications.yml", __FILE__)))
|
4
|
+
|
5
|
+
# Client Spec
|
6
|
+
describe Subordinate::Client do
|
7
|
+
before do
|
8
|
+
Subordinate.reset!
|
9
|
+
Subordinate.configure do |c|
|
10
|
+
c.subdomain = auth["subdomain"]
|
11
|
+
c.domain = auth["domain"]
|
12
|
+
c.port = auth["port"]
|
13
|
+
c.ssl = false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:subordinate) { Subordinate::Client.new(:username => auth["username"], :api_token => auth["token"]) }
|
17
|
+
|
18
|
+
describe "#job", :vcr do
|
19
|
+
let(:current_response) { subordinate.job(auth["job"]) }
|
20
|
+
|
21
|
+
it "should return the job response" do
|
22
|
+
current_response.should_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
context "methods" do
|
26
|
+
it "responds to .actions" do
|
27
|
+
current_response.should respond_to(:actions)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "responds to .description" do
|
31
|
+
current_response.should respond_to(:description)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "responds to .displayName" do
|
35
|
+
current_response.should respond_to(:displayName)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "responds to .displayNameOrNull" do
|
39
|
+
current_response.should respond_to(:displayNameOrNull)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "responds to .name" do
|
43
|
+
current_response.should respond_to(:name)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "responds to .url" do
|
47
|
+
current_response.should respond_to(:url)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "responds to .buildable" do
|
51
|
+
current_response.should respond_to(:buildable)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "responds to .builds" do
|
55
|
+
current_response.should respond_to(:builds)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "responds to .color" do
|
59
|
+
current_response.should respond_to(:color)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "responds to .firstBuild" do
|
63
|
+
current_response.should respond_to(:firstBuild)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "responds to .healthReport" do
|
67
|
+
current_response.should respond_to(:healthReport)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "responds to .inQueue" do
|
71
|
+
current_response.should respond_to(:inQueue)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "responds to .keepDependencies" do
|
75
|
+
current_response.should respond_to(:keepDependencies)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "responds to .lastBuild" do
|
79
|
+
current_response.should respond_to(:lastBuild)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "responds to .lastCompletedBuild" do
|
83
|
+
current_response.should respond_to(:lastCompletedBuild)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "responds to .lastFailedBuild" do
|
87
|
+
current_response.should respond_to(:lastFailedBuild)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "responds to .lastStableBuild" do
|
91
|
+
current_response.should respond_to(:lastStableBuild)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "responds to .lastSuccessfulBuild" do
|
95
|
+
current_response.should respond_to(:lastSuccessfulBuild)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "responds to .lastUnstableBuild" do
|
99
|
+
current_response.should respond_to(:lastUnstableBuild)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "responds to .lastUnsuccessfulBuild" do
|
103
|
+
current_response.should respond_to(:lastUnsuccessfulBuild)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "responds to .nextBuildNumber" do
|
107
|
+
current_response.should respond_to(:nextBuildNumber)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "responds to .property" do
|
111
|
+
current_response.should respond_to(:property)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "responds to .queueItem" do
|
115
|
+
current_response.should respond_to(:queueItem)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "responds to .concurrentBuild" do
|
119
|
+
current_response.should respond_to(:concurrentBuild)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "responds to .downstreamProjects" do
|
123
|
+
current_response.should respond_to(:downstreamProjects)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "responds to .scm" do
|
127
|
+
current_response.should respond_to(:scm)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "responds to .upstreamProjects" do
|
131
|
+
current_response.should respond_to(:upstreamProjects)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "#build_job" do
|
137
|
+
it "builds the job specified" do
|
138
|
+
stub_request(:post, "#{subordinate.api_endpoint}/job/#{auth['job']}/build").
|
139
|
+
to_return(:status => 302, :body => "", :headers => {})
|
140
|
+
|
141
|
+
subordinate.build_job(auth["job"]).should == 302
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#disable_job" do
|
146
|
+
it "disables the specified job" do
|
147
|
+
stub_request(:post, "#{subordinate.api_endpoint}/job/#{auth['job']}/disable").
|
148
|
+
to_return(:status => 302, :body => "", :headers => {})
|
149
|
+
|
150
|
+
subordinate.disable_job(auth["job"]).should == 302
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#enable_job" do
|
155
|
+
it "enables the specified job" do
|
156
|
+
stub_request(:post, "#{subordinate.api_endpoint}/job/#{auth['job']}/enable").
|
157
|
+
to_return(:status => 302, :body => "", :headers => {})
|
158
|
+
|
159
|
+
subordinate.enable_job(auth["job"]).should == 302
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#delete_job" do
|
164
|
+
it "deletes the specified job" do
|
165
|
+
stub_request(:post, "#{subordinate.api_endpoint}/job/#{auth['job']}/delete").
|
166
|
+
to_return(:status => 302, :body => "", :headers => {})
|
167
|
+
|
168
|
+
subordinate.delete_job(auth["job"]).should == 302
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
auth = authentications = YAML::load(File.open(File.expand_path("../../../fixtures/authentications.yml", __FILE__)))
|
4
|
+
|
5
|
+
# Client Spec
|
6
|
+
describe Subordinate::Client do
|
7
|
+
before do
|
8
|
+
Subordinate.reset!
|
9
|
+
Subordinate.configure do |c|
|
10
|
+
c.subdomain = auth["subdomain"]
|
11
|
+
c.domain = auth["domain"]
|
12
|
+
c.port = auth["port"]
|
13
|
+
c.ssl = false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:subordinate) { Subordinate::Client.new(:username => auth["username"], :api_token => auth["token"]) }
|
17
|
+
|
18
|
+
describe "#root", :vcr do
|
19
|
+
let(:current_response) { subordinate.root }
|
20
|
+
|
21
|
+
it "returns the root response", :vcr do
|
22
|
+
current_response.should_not be_nil
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "methods" do
|
26
|
+
it "contains the assignedLabels" do
|
27
|
+
current_response.should respond_to(:assignedLabels)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "contains the mode" do
|
31
|
+
current_response.should respond_to(:mode)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "contains the nodeDescription" do
|
35
|
+
current_response.should respond_to(:nodeDescription)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "contains the nodeName" do
|
39
|
+
current_response.should respond_to(:nodeName)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "contains the numExecutors" do
|
43
|
+
current_response.should respond_to(:numExecutors)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "contains the description" do
|
47
|
+
current_response.should respond_to(:description)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "contains the jobs" do
|
51
|
+
current_response.should respond_to(:jobs)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "contains the overallLoad" do
|
55
|
+
current_response.should respond_to(:overallLoad)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "contains the primaryView" do
|
59
|
+
current_response.should respond_to(:primaryView)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "contains the quietingDown" do
|
63
|
+
current_response.should respond_to(:quietingDown)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "contains the slaveAgentPort" do
|
67
|
+
current_response.should respond_to(:slaveAgentPort)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "contains the unlabeledLoad" do
|
71
|
+
current_response.should respond_to(:unlabeledLoad)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "contains the useCrumbs" do
|
75
|
+
current_response.should respond_to(:useCrumbs)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "contains the useSecurity" do
|
79
|
+
current_response.should respond_to(:useSecurity)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "contains the views" do
|
83
|
+
current_response.should respond_to(:views)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#quiet_down" do
|
89
|
+
it "will shut down the server" do
|
90
|
+
stub_request(:post, "#{subordinate.api_endpoint}/quietDown").
|
91
|
+
to_return(:status => 302, :body => "", :headers => {})
|
92
|
+
|
93
|
+
subordinate.quiet_down.should == 302
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#cancel_quiet_down" do
|
98
|
+
it "will cancel a shut down request to the server" do
|
99
|
+
stub_request(:post, "#{subordinate.api_endpoint}/cancelQuietDown").
|
100
|
+
to_return(:status => 302, :body => "", :headers => {})
|
101
|
+
|
102
|
+
subordinate.cancel_quiet_down.should == 302
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Because vcr makes real requests the first time when redoing cassettes the restart specs must be
|
107
|
+
# commented out since random order is used.
|
108
|
+
describe "#restart" do
|
109
|
+
it "will force restart the jenkins server" do
|
110
|
+
stub_request(:post, "#{subordinate.api_endpoint}/restart").
|
111
|
+
to_return(:status => 302, :body => "", :headers => {})
|
112
|
+
|
113
|
+
subordinate.restart.should == 302
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#safe_restart" do
|
118
|
+
it "will restart the jenkins server" do
|
119
|
+
stub_request(:post, "#{subordinate.api_endpoint}/safeRestart").
|
120
|
+
to_return(:status => 302, :body => "", :headers => {})
|
121
|
+
|
122
|
+
subordinate.safe_restart.should == 302
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
auth = authentications = YAML::load(File.open(File.expand_path("../../fixtures/authentications.yml", __FILE__)))
|
4
|
+
|
5
|
+
# Client Spec
|
6
|
+
describe Subordinate::Client do
|
7
|
+
before do
|
8
|
+
Subordinate.reset!
|
9
|
+
Subordinate.configure do |c|
|
10
|
+
c.subdomain = auth["subdomain"]
|
11
|
+
c.domain = auth["domain"]
|
12
|
+
c.port = auth["port"]
|
13
|
+
c.ssl = false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#initialize" do
|
18
|
+
it "can be initialized" do
|
19
|
+
Subordinate::Client.new.class.should == Subordinate::Client
|
20
|
+
end
|
21
|
+
|
22
|
+
it "works with basic username and api token", :vcr do
|
23
|
+
Subordinate::Client.new(:username => auth["username"], :api_token => auth["token"]).root
|
24
|
+
.should_not
|
25
|
+
raise_exception
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/subordinate.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'subordinate/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "subordinate"
|
8
|
+
gem.version = Subordinate::VERSION
|
9
|
+
gem.authors = ["Jason Truluck"]
|
10
|
+
gem.email = ["jason.truluck@gmail.com"]
|
11
|
+
gem.description = %q{Jenkins API wrapper}
|
12
|
+
gem.summary = gem.description
|
13
|
+
gem.homepage = "https://github.com/jasontruluck/subordinate"
|
14
|
+
|
15
|
+
# gem.add_dependency "faraday"
|
16
|
+
gem.add_dependency "faraday"
|
17
|
+
gem.add_dependency "faraday_middleware"
|
18
|
+
gem.add_dependency "hashie"
|
19
|
+
gem.add_development_dependency "rspec"
|
20
|
+
gem.add_development_dependency "rake"
|
21
|
+
gem.add_development_dependency "vcr"
|
22
|
+
gem.add_development_dependency "mocha"
|
23
|
+
gem.add_development_dependency "webmock"
|
24
|
+
gem.add_development_dependency "simplecov"
|
25
|
+
gem.add_development_dependency "capybara"
|
26
|
+
gem.add_development_dependency "yard"
|
27
|
+
gem.add_development_dependency "redcarpet"
|
28
|
+
|
29
|
+
gem.files = `git ls-files`.split($/)
|
30
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
31
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
32
|
+
gem.require_paths = ["lib"]
|
33
|
+
end
|