jenkins 0.6.6 → 0.6.8
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.
- data/Changelog.md +4 -0
- data/features/manage_jobs.feature +48 -0
- data/jenkins.gemspec +1 -1
- data/lib/jenkins/api.rb +35 -12
- data/lib/jenkins/cli.rb +76 -30
- data/lib/jenkins/job_config_builder.rb +109 -4
- data/lib/jenkins/version.rb +1 -1
- data/spec/job_config_builder_spec.rb +76 -4
- metadata +24 -24
data/Changelog.md
CHANGED
@@ -94,6 +94,54 @@ Feature: Create and manage jobs
|
|
94
94
|
</scm>
|
95
95
|
"""
|
96
96
|
|
97
|
+
Scenario: Update the SCM configuration of an existing jenkins job (jenkins update . --scm URI --scm-branches='master')
|
98
|
+
Given I am in the "ruby" project folder
|
99
|
+
And the project uses "git" scm
|
100
|
+
And I run local executable "jenkins" with arguments "create . --scm git://localhost/myapp.git --scm-branches 'master,other' --host localhost --port 3010"
|
101
|
+
Then I should see "Added ruby project 'ruby' to Jenkins."
|
102
|
+
And I run local executable "jenkins" with arguments "update . --scm git://localhost/myapp_new.git --scm-branches 'master' --host localhost --port 3010"
|
103
|
+
Then I should see "Updated ruby project 'ruby'."
|
104
|
+
And the job "ruby" config "scm" should be:
|
105
|
+
"""
|
106
|
+
<scm class="hudson.plugins.git.GitSCM">
|
107
|
+
<configVersion>1</configVersion>
|
108
|
+
<remoteRepositories>
|
109
|
+
<org.spearce.jgit.transport.RemoteConfig>
|
110
|
+
<string>origin</string>
|
111
|
+
<int>5</int>
|
112
|
+
<string>fetch</string>
|
113
|
+
<string>+refs/heads/*:refs/remotes/origin/*</string>
|
114
|
+
<string>receivepack</string>
|
115
|
+
<string>git-upload-pack</string>
|
116
|
+
<string>uploadpack</string>
|
117
|
+
<string>git-upload-pack</string>
|
118
|
+
<string>url</string>
|
119
|
+
<string>git://localhost/myapp_new.git</string>
|
120
|
+
<string>tagopt</string>
|
121
|
+
<string />
|
122
|
+
</org.spearce.jgit.transport.RemoteConfig>
|
123
|
+
</remoteRepositories>
|
124
|
+
<branches>
|
125
|
+
<hudson.plugins.git.BranchSpec>
|
126
|
+
<name>master</name>
|
127
|
+
</hudson.plugins.git.BranchSpec>
|
128
|
+
</branches>
|
129
|
+
<localBranch />
|
130
|
+
<mergeOptions />
|
131
|
+
<recursiveSubmodules>false</recursiveSubmodules>
|
132
|
+
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
133
|
+
<authorOrCommitter>false</authorOrCommitter>
|
134
|
+
<clean>false</clean>
|
135
|
+
<wipeOutWorkspace>false</wipeOutWorkspace>
|
136
|
+
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser" />
|
137
|
+
<gitTool>Default</gitTool>
|
138
|
+
<submoduleCfg class="list" />
|
139
|
+
<relativeTargetDir />
|
140
|
+
<excludedRegions />
|
141
|
+
<excludedUsers />
|
142
|
+
</scm>
|
143
|
+
"""
|
144
|
+
|
97
145
|
Scenario: Setup jenkins job with multiple rubies (jenkins create --rubies '1.8.7,rbx-head,jruby')
|
98
146
|
Given I am in the "ruby" project folder
|
99
147
|
And the project uses "git" scm
|
data/jenkins.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_dependency("hpricot")
|
27
27
|
s.add_dependency("json_pure", ">= 1.5.1")
|
28
28
|
|
29
|
-
s.add_development_dependency
|
29
|
+
s.add_development_dependency "jenkins-war", ">= 1.396"
|
30
30
|
s.add_development_dependency "rake"
|
31
31
|
s.add_development_dependency "cucumber", "~> 1.0"
|
32
32
|
s.add_development_dependency "rspec", "~> 2.0"
|
data/lib/jenkins/api.rb
CHANGED
@@ -75,17 +75,7 @@ module Jenkins
|
|
75
75
|
cache_configuration!
|
76
76
|
true
|
77
77
|
else
|
78
|
-
|
79
|
-
doc = Hpricot(res.body)
|
80
|
-
error_msg = doc.search("td#main-panel p")
|
81
|
-
unless error_msg.inner_text.blank?
|
82
|
-
$stderr.puts error_msg.inner_text
|
83
|
-
else
|
84
|
-
# TODO - what are the errors we get?
|
85
|
-
puts "Server error:"
|
86
|
-
p res.code
|
87
|
-
puts res.body
|
88
|
-
end
|
78
|
+
show_me_the_error(res)
|
89
79
|
false
|
90
80
|
end
|
91
81
|
rescue REXML::ParseException => e
|
@@ -94,6 +84,25 @@ module Jenkins
|
|
94
84
|
end
|
95
85
|
end
|
96
86
|
|
87
|
+
# returns true if successfully updated a job on Jenkins
|
88
|
+
# +job_config+ is a Jenkins::JobConfigBuilder instance
|
89
|
+
#
|
90
|
+
# returns true if successful, else false
|
91
|
+
#
|
92
|
+
# TODO Exceptions?
|
93
|
+
def self.update_job(name, job_config)
|
94
|
+
res = post "#{job_url name}/config.xml", {
|
95
|
+
:body => job_config.to_xml, :format => :xml, :headers => { 'content-type' => 'application/xml' }
|
96
|
+
}
|
97
|
+
if res.code.to_i == 200
|
98
|
+
cache_configuration!
|
99
|
+
true
|
100
|
+
else
|
101
|
+
show_me_the_error(res)
|
102
|
+
false
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
97
106
|
# Attempts to delete a job +name+
|
98
107
|
def self.delete_job(name)
|
99
108
|
res = post_plain "#{job_url name}/doDelete"
|
@@ -279,7 +288,21 @@ module Jenkins
|
|
279
288
|
end
|
280
289
|
|
281
290
|
def self.job_url(name)
|
282
|
-
"#{base_uri}/job/#{name}"
|
291
|
+
"#{base_uri}/job/#{URI.escape(name)}"
|
292
|
+
end
|
293
|
+
|
294
|
+
def self.show_me_the_error(response)
|
295
|
+
require "hpricot"
|
296
|
+
doc = Hpricot(response.body)
|
297
|
+
error_msg = doc.search("td#main-panel p")
|
298
|
+
unless error_msg.inner_text.blank?
|
299
|
+
$stderr.puts error_msg.inner_text
|
300
|
+
else
|
301
|
+
# TODO - what are the errors we get?
|
302
|
+
puts "Server error:"
|
303
|
+
p response.code
|
304
|
+
puts response.body
|
305
|
+
end
|
283
306
|
end
|
284
307
|
end
|
285
308
|
end
|
data/lib/jenkins/cli.rb
CHANGED
@@ -50,42 +50,62 @@ module Jenkins
|
|
50
50
|
def create(project_path)
|
51
51
|
select_jenkins_server(options)
|
52
52
|
FileUtils.chdir(project_path) do
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
unless (options[:template] == "none" || options[:template] == "erlang" || options[:"no-template"]) || File.exists?("Gemfile")
|
57
|
-
error "Ruby/Rails projects without a Gemfile are currently unsupported."
|
58
|
-
end
|
53
|
+
scm = discover_scm(options)
|
54
|
+
ruby_or_rails_project_without_gemfile?(options)
|
59
55
|
begin
|
60
56
|
template = options[:"no-template"] ? 'none' : options[:template]
|
61
|
-
job_config =
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
c.assigned_node = options[:"assigned-node"] if options[:"assigned-node"]
|
67
|
-
c.public_scm = options[:"public-scm"]
|
68
|
-
end
|
69
|
-
name = File.basename(FileUtils.pwd)
|
70
|
-
if Jenkins::Api.create_job(name, job_config, options)
|
71
|
-
build_url = "#{@uri}/job/#{name.gsub(/\s/,'%20')}/build"
|
72
|
-
shell.say "Added#{' ' + template unless template == 'none'} project '#{name}' to Jenkins.", :green
|
57
|
+
job_config = build_job_config(scm, template, options)
|
58
|
+
|
59
|
+
if Jenkins::Api.create_job(project_name, job_config, options)
|
60
|
+
build_url = "#{@uri}/job/#{project_name.gsub(/\s/,'%20')}/build"
|
61
|
+
shell.say "Added#{' ' + template unless template == 'none'} project '#{project_name}' to Jenkins.", :green
|
73
62
|
unless options[:"no-build"]
|
74
63
|
shell.say "Triggering initial build..."
|
75
|
-
Jenkins::Api.build_job(
|
64
|
+
Jenkins::Api.build_job(project_name)
|
76
65
|
shell.say "Trigger additional builds via:"
|
77
66
|
else
|
78
67
|
shell.say "Trigger builds via:"
|
79
68
|
end
|
80
69
|
shell.say " URL: "; shell.say "#{build_url}", :yellow
|
81
|
-
shell.say " CLI: "; shell.say "#{cmd} build #{
|
70
|
+
shell.say " CLI: "; shell.say "#{cmd} build #{project_name}", :yellow
|
82
71
|
else
|
83
|
-
error "Failed to create project '#{
|
72
|
+
error "Failed to create project '#{project_name}'"
|
84
73
|
end
|
85
74
|
rescue Jenkins::JobConfigBuilder::InvalidTemplate
|
86
75
|
error "Invalid job template '#{template}'."
|
87
76
|
rescue Jenkins::Api::JobAlreadyExistsError
|
88
|
-
error "Job '#{
|
77
|
+
error "Job '#{project_name}' already exists."
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "update project_path [options]", "update the configuration for your project"
|
83
|
+
common_options
|
84
|
+
method_option :rubies, :desc => "run tests against multiple explicit rubies via RVM", :type => :string
|
85
|
+
method_option :"node-labels", :desc => "run tests against multiple slave nodes by their label (comma separated)"
|
86
|
+
method_option :"assigned-node", :desc => "only use slave nodes with this label (similar to --node-labels)"
|
87
|
+
method_option :"no-build", :desc => "create job without initial build", :type => :boolean, :default => false
|
88
|
+
method_option :"scm", :desc => "specific SCM URI", :type => :string
|
89
|
+
method_option :"scm-branches", :desc => "list of branches to build from (comma separated)", :type => :string, :default => "master"
|
90
|
+
method_option :"public-scm", :desc => "use public scm URL", :type => :boolean, :default => false
|
91
|
+
method_option :template, :desc => "template of job steps (available: #{JobConfigBuilder::VALID_JOB_TEMPLATES.join ','})", :default => 'ruby'
|
92
|
+
method_option :"no-template", :desc => "do not use a template of default steps; avoids Gemfile requirement", :type => :boolean, :default => false
|
93
|
+
def update(project_path)
|
94
|
+
select_jenkins_server(options)
|
95
|
+
FileUtils.chdir(project_path) do
|
96
|
+
scm = discover_scm(options)
|
97
|
+
ruby_or_rails_project_without_gemfile?(options)
|
98
|
+
begin
|
99
|
+
template = options[:"no-template"] ? 'none' : options[:template]
|
100
|
+
job_config = build_job_config(scm, template, options)
|
101
|
+
|
102
|
+
if Jenkins::Api.update_job(project_name, job_config)
|
103
|
+
shell.say "Updated#{' ' + template unless template == 'none'} project '#{project_name}'.", :green
|
104
|
+
else
|
105
|
+
error "Failed to update project '#{project_name}'"
|
106
|
+
end
|
107
|
+
rescue Jenkins::JobConfigBuilder::InvalidTemplate
|
108
|
+
error "Invalid job template '#{template}'."
|
89
109
|
end
|
90
110
|
end
|
91
111
|
end
|
@@ -95,11 +115,10 @@ module Jenkins
|
|
95
115
|
def build(project_path = ".")
|
96
116
|
select_jenkins_server(options)
|
97
117
|
FileUtils.chdir(project_path) do
|
98
|
-
|
99
|
-
|
100
|
-
shell.say "Build for '#{name}' running now..."
|
118
|
+
if Jenkins::Api.build_job(project_name)
|
119
|
+
shell.say "Build for '#{project_name}' running now..."
|
101
120
|
else
|
102
|
-
error "No job '#{
|
121
|
+
error "No job '#{project_name}' on server."
|
103
122
|
end
|
104
123
|
end
|
105
124
|
end
|
@@ -109,11 +128,10 @@ module Jenkins
|
|
109
128
|
def remove(project_path)
|
110
129
|
select_jenkins_server(options)
|
111
130
|
FileUtils.chdir(project_path) do
|
112
|
-
|
113
|
-
|
114
|
-
shell.say "Removed project '#{name}' from Jenkins."
|
131
|
+
if Jenkins::Api.delete_job(project_name)
|
132
|
+
shell.say "Removed project '#{project_name}' from Jenkins."
|
115
133
|
else
|
116
|
-
error "Failed to delete project '#{
|
134
|
+
error "Failed to delete project '#{project_name}'."
|
117
135
|
end
|
118
136
|
end
|
119
137
|
end
|
@@ -298,5 +316,33 @@ USEAGE
|
|
298
316
|
def cmd
|
299
317
|
ENV['CUCUMBER_RUNNING'] ? 'jenkins' : $0
|
300
318
|
end
|
319
|
+
|
320
|
+
def project_name
|
321
|
+
@project_name ||= File.basename(FileUtils.pwd)
|
322
|
+
end
|
323
|
+
|
324
|
+
def build_job_config(scm, template, options)
|
325
|
+
Jenkins::JobConfigBuilder.new(template) do |c|
|
326
|
+
c.rubies = options[:rubies].split(/\s*,\s*/) if options[:rubies]
|
327
|
+
c.node_labels = options[:"node-labels"].split(/\s*,\s*/) if options[:"node-labels"]
|
328
|
+
c.scm = scm.url
|
329
|
+
c.scm_branches = options[:"scm-branches"].split(/\s*,\s*/)
|
330
|
+
c.assigned_node = options[:"assigned-node"] if options[:"assigned-node"]
|
331
|
+
c.public_scm = options[:"public-scm"]
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def ruby_or_rails_project_without_gemfile?(options)
|
336
|
+
unless (options[:template] == "none" || options[:template] == "erlang" || options[:"no-template"]) || File.exists?("Gemfile")
|
337
|
+
error "Ruby/Rails projects without a Gemfile are currently unsupported."
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def discover_scm(options)
|
342
|
+
unless scm = Jenkins::ProjectScm.discover(options[:scm])
|
343
|
+
error "Cannot determine project SCM. Currently supported: #{Jenkins::ProjectScm.supported}"
|
344
|
+
end
|
345
|
+
scm
|
346
|
+
end
|
301
347
|
end
|
302
348
|
end
|
@@ -4,14 +4,21 @@ module Jenkins
|
|
4
4
|
class JobConfigBuilder
|
5
5
|
attr_accessor :job_type
|
6
6
|
attr_accessor :steps, :rubies
|
7
|
+
attr_accessor :triggers
|
8
|
+
attr_accessor :publishers
|
9
|
+
attr_accessor :log_rotate
|
7
10
|
attr_accessor :scm, :public_scm, :scm_branches
|
8
|
-
attr_accessor :scm, :public_scm, :git_branches
|
9
11
|
attr_accessor :assigned_node, :node_labels # TODO just one of these
|
10
12
|
attr_accessor :envfile
|
11
13
|
|
12
14
|
InvalidTemplate = Class.new(StandardError)
|
13
15
|
|
14
16
|
VALID_JOB_TEMPLATES = %w[none rails rails3 ruby rubygem erlang]
|
17
|
+
JOB_TRIGGER_THRESHOLDS = {
|
18
|
+
"SUCCESS" => {:ordinal => 0, :color => "BLUE"},
|
19
|
+
"UNSTABLE" => {:ordinal => 1, :color => "YELLOW"},
|
20
|
+
"FAILURE" => {:ordinal => 2, :color => "RED"}
|
21
|
+
}
|
15
22
|
|
16
23
|
# +job_type+ - template of default steps to create with the job
|
17
24
|
# +steps+ - array of [:method, cmd], e.g. [:build_shell_step, "bundle initial"]
|
@@ -20,7 +27,10 @@ module Jenkins
|
|
20
27
|
# +public_scm+ - convert the +scm+ URL to a publicly accessible URL for the Jenkins job config.
|
21
28
|
# +scm_branches+ - array of branches to run builds. Default: ['master']
|
22
29
|
# +rubies+ - list of RVM rubies to run tests (via Jenkins Axes).
|
30
|
+
# +triggers+ - list of triggers to start the build. Currently only support time triggers
|
23
31
|
# +assigned_node+ - restrict this job to running on slaves with these labels (space separated)
|
32
|
+
# +publishers+ - define publishers to be performed after a build
|
33
|
+
# +log_rotate+ - define log rotation
|
24
34
|
def initialize(job_type = :ruby, &block)
|
25
35
|
self.job_type = job_type.to_s if job_type
|
26
36
|
|
@@ -36,6 +46,7 @@ module Jenkins
|
|
36
46
|
b.tag!(matrix_project? ? "matrix-project" : "project") do
|
37
47
|
b.actions
|
38
48
|
b.description
|
49
|
+
build_log_rotator b
|
39
50
|
b.keepDependencies false
|
40
51
|
b.properties
|
41
52
|
build_scm b
|
@@ -43,11 +54,11 @@ module Jenkins
|
|
43
54
|
b.canRoam !assigned_node
|
44
55
|
b.disabled false
|
45
56
|
b.blockBuildWhenUpstreamBuilding false
|
46
|
-
b
|
57
|
+
build_triggers b
|
47
58
|
b.concurrentBuild false
|
48
59
|
build_axes b if matrix_project?
|
49
60
|
build_steps b
|
50
|
-
b
|
61
|
+
build_publishers b
|
51
62
|
build_wrappers b
|
52
63
|
b.runSequentially false if matrix_project?
|
53
64
|
end
|
@@ -174,6 +185,100 @@ module Jenkins
|
|
174
185
|
b.buildWrappers
|
175
186
|
end
|
176
187
|
end
|
188
|
+
|
189
|
+
# Example
|
190
|
+
# <triggers class="vector">
|
191
|
+
# <hudson.triggers.TimerTrigger>
|
192
|
+
# <spec>* * * * *</spec>
|
193
|
+
# </hudson.triggers.TimerTrigger>
|
194
|
+
# </triggers>
|
195
|
+
def build_triggers(b)
|
196
|
+
if triggers
|
197
|
+
b.triggers :class => "vector" do
|
198
|
+
triggers.each do |trigger|
|
199
|
+
case trigger[:class]
|
200
|
+
when :timer
|
201
|
+
b.tag! "hudson.triggers.TimerTrigger" do
|
202
|
+
b.spec trigger[:spec]
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else
|
208
|
+
b.triggers :class => "vector"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Example
|
213
|
+
# <logRotator>
|
214
|
+
# <daysToKeep>14</daysToKeep>
|
215
|
+
# <numToKeep>-1</numToKeep>
|
216
|
+
# <artifactDaysToKeep>-1</artifactDaysToKeep>
|
217
|
+
# <artifactNumToKeep>-1</artifactNumToKeep>
|
218
|
+
# </logRotator>
|
219
|
+
def build_log_rotator(b)
|
220
|
+
if log_rotate
|
221
|
+
b.logRotator do
|
222
|
+
b.daysToKeep log_rotate[:days_to_keep] || -1
|
223
|
+
b.numToKeep log_rotate[:num_to_keep] || -1
|
224
|
+
b.artifactDaysToKeep log_rotate[:artifact_days_to_keep] || -1
|
225
|
+
b.artifactNumToKeep log_rotate[:artifact_num_to_keep] || -1
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# Example
|
231
|
+
# <publishers>
|
232
|
+
# <hudson.plugins.chucknorris.CordellWalkerRecorder>
|
233
|
+
# <factGenerator/>
|
234
|
+
# </hudson.plugins.chucknorris.CordellWalkerRecorder>
|
235
|
+
# <hudson.tasks.BuildTrigger>
|
236
|
+
# <childProjects>Dependent Job, Even more dependent job</childProjects>
|
237
|
+
# <threshold>
|
238
|
+
# <name>SUCCESS</name>
|
239
|
+
# <ordinal>0</ordinal>
|
240
|
+
# <color>BLUE</color>
|
241
|
+
# </threshold>
|
242
|
+
# </hudson.tasks.BuildTrigger>
|
243
|
+
# <hudson.tasks.Mailer>
|
244
|
+
# <recipients>some.guy@example.com, another.guy@example.com</recipients>
|
245
|
+
# <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
|
246
|
+
# <sendToIndividuals>true</sendToIndividuals>
|
247
|
+
# </hudson.tasks.Mailer>
|
248
|
+
# </publishers>
|
249
|
+
def build_publishers(b)
|
250
|
+
if publishers
|
251
|
+
b.publishers do
|
252
|
+
publishers.each do |publisher|
|
253
|
+
publisher_name, params = publisher.to_a.first
|
254
|
+
case publisher_name
|
255
|
+
when :mailer
|
256
|
+
b.tag! "hudson.tasks.Mailer" do
|
257
|
+
b.recipients params.join(', ')
|
258
|
+
b.dontNotifyEveryUnstableBuild false
|
259
|
+
b.sendToIndividuals true
|
260
|
+
end
|
261
|
+
when :job_triggers
|
262
|
+
b.tag! "hudson.tasks.BuildTrigger" do
|
263
|
+
b.childProjects params[:projects].join(', ')
|
264
|
+
b.threshold do
|
265
|
+
trigger_event = params[:on] || "SUCCESS"
|
266
|
+
b.name trigger_event
|
267
|
+
b.ordinal JOB_TRIGGER_THRESHOLDS[trigger_event][:ordinal]
|
268
|
+
b.color JOB_TRIGGER_THRESHOLDS[trigger_event][:color]
|
269
|
+
end
|
270
|
+
end
|
271
|
+
when :chuck_norris
|
272
|
+
b.tag! "hudson.plugins.chucknorris.CordellWalkerRecorder" do
|
273
|
+
b.factGenerator
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
else
|
279
|
+
b.publishers
|
280
|
+
end
|
281
|
+
end
|
177
282
|
|
178
283
|
# The important sequence of steps that are run to process a job build.
|
179
284
|
# Can be defaulted by the +job_type+ using +default_steps(job_type)+,
|
@@ -289,4 +394,4 @@ module Jenkins
|
|
289
394
|
end
|
290
395
|
end
|
291
396
|
end
|
292
|
-
end
|
397
|
+
end
|
data/lib/jenkins/version.rb
CHANGED
@@ -19,7 +19,6 @@ describe Jenkins::JobConfigBuilder do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
22
|
describe "rails job; single axis" do
|
24
23
|
before do
|
25
24
|
@config = Jenkins::JobConfigBuilder.new(:rails) do |c|
|
@@ -31,8 +30,6 @@ describe Jenkins::JobConfigBuilder do
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
33
|
describe "many rubies" do
|
37
34
|
before do
|
38
35
|
@config = Jenkins::JobConfigBuilder.new(:ruby) do |c|
|
@@ -135,6 +132,81 @@ describe Jenkins::JobConfigBuilder do
|
|
135
132
|
end
|
136
133
|
end
|
137
134
|
|
135
|
+
describe "setup log rotator" do
|
136
|
+
before do
|
137
|
+
@config = Jenkins::JobConfigBuilder.new(:rails) do |c|
|
138
|
+
c.log_rotate = { :days_to_keep => 14 }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'builds config.xml' do
|
143
|
+
xml_bite = <<-XML.gsub(/^ /, '')
|
144
|
+
<logRotator>
|
145
|
+
<daysToKeep>14</daysToKeep>
|
146
|
+
<numToKeep>-1</numToKeep>
|
147
|
+
<artifactDaysToKeep>-1</artifactDaysToKeep>
|
148
|
+
<artifactNumToKeep>-1</artifactNumToKeep>
|
149
|
+
</logRotator>
|
150
|
+
XML
|
151
|
+
Hpricot.XML(@config.to_xml).search("logRotator").to_s.should == xml_bite.strip
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "setup build triggers" do
|
156
|
+
before do
|
157
|
+
@config = Jenkins::JobConfigBuilder.new(:rails) do |c|
|
158
|
+
c.triggers = [{:class => :timer, :spec => "5 * * * *"}]
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'builds config.xml' do
|
163
|
+
xml_bite = <<-XML.gsub(/^ /, '')
|
164
|
+
<triggers class="vector">
|
165
|
+
<hudson.triggers.TimerTrigger>
|
166
|
+
<spec>5 * * * *</spec>
|
167
|
+
</hudson.triggers.TimerTrigger>
|
168
|
+
</triggers>
|
169
|
+
XML
|
170
|
+
Hpricot.XML(@config.to_xml).search("triggers").to_s.should == xml_bite.strip
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "setup publishers for a build" do
|
175
|
+
before do
|
176
|
+
@config = Jenkins::JobConfigBuilder.new(:none) do |c|
|
177
|
+
c.publishers = [
|
178
|
+
{ :chuck_norris => true },
|
179
|
+
{ :job_triggers => { :projects => ["Dependent Job", "Even more dependent job"], :on => "FAILURE" } },
|
180
|
+
{ :mailer => ["some.guy@example.com", "another.guy@example.com"] }
|
181
|
+
]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'builds config.xml' do
|
186
|
+
xml_bite = <<-XML.gsub(/^ /, '')
|
187
|
+
<publishers>
|
188
|
+
<hudson.plugins.chucknorris.CordellWalkerRecorder>
|
189
|
+
<factGenerator />
|
190
|
+
</hudson.plugins.chucknorris.CordellWalkerRecorder>
|
191
|
+
<hudson.tasks.BuildTrigger>
|
192
|
+
<childProjects>Dependent Job, Even more dependent job</childProjects>
|
193
|
+
<threshold>
|
194
|
+
<name>FAILURE</name>
|
195
|
+
<ordinal>2</ordinal>
|
196
|
+
<color>RED</color>
|
197
|
+
</threshold>
|
198
|
+
</hudson.tasks.BuildTrigger>
|
199
|
+
<hudson.tasks.Mailer>
|
200
|
+
<recipients>some.guy@example.com, another.guy@example.com</recipients>
|
201
|
+
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
|
202
|
+
<sendToIndividuals>true</sendToIndividuals>
|
203
|
+
</hudson.tasks.Mailer>
|
204
|
+
</publishers>
|
205
|
+
XML
|
206
|
+
Hpricot.XML(@config.to_xml).search("publishers").to_s.should == xml_bite.strip
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
138
210
|
describe "erlang job; single axis" do
|
139
211
|
before do
|
140
212
|
@config = Jenkins::JobConfigBuilder.new(:erlang) do |c|
|
@@ -147,4 +219,4 @@ describe Jenkins::JobConfigBuilder do
|
|
147
219
|
end
|
148
220
|
|
149
221
|
|
150
|
-
end
|
222
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jenkins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: term-ansicolor
|
17
|
-
requirement: &
|
17
|
+
requirement: &70195831626640 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70195831626640
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: httparty
|
28
|
-
requirement: &
|
28
|
+
requirement: &70195831626120 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.6.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70195831626120
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: builder
|
39
|
-
requirement: &
|
39
|
+
requirement: &70195831625640 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 2.1.2
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70195831625640
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: thor
|
50
|
-
requirement: &
|
50
|
+
requirement: &70195831625180 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 0.14.2
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70195831625180
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: hpricot
|
61
|
-
requirement: &
|
61
|
+
requirement: &70195831624800 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70195831624800
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: json_pure
|
72
|
-
requirement: &
|
72
|
+
requirement: &70195831624260 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 1.5.1
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70195831624260
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: jenkins-war
|
83
|
-
requirement: &
|
83
|
+
requirement: &70195831623760 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '1.396'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70195831623760
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: rake
|
94
|
-
requirement: &
|
94
|
+
requirement: &70195831639760 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *70195831639760
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: cucumber
|
105
|
-
requirement: &
|
105
|
+
requirement: &70195831639220 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
@@ -110,10 +110,10 @@ dependencies:
|
|
110
110
|
version: '1.0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *70195831639220
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: rspec
|
116
|
-
requirement: &
|
116
|
+
requirement: &70195831638640 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ~>
|
@@ -121,10 +121,10 @@ dependencies:
|
|
121
121
|
version: '2.0'
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
|
-
version_requirements: *
|
124
|
+
version_requirements: *70195831638640
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: awesome_print
|
127
|
-
requirement: &
|
127
|
+
requirement: &70195831638140 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
@@ -132,7 +132,7 @@ dependencies:
|
|
132
132
|
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
|
-
version_requirements: *
|
135
|
+
version_requirements: *70195831638140
|
136
136
|
description: A suite of utilities for bringing continous integration to your projects
|
137
137
|
(not the other way around) with jenkins CI
|
138
138
|
email:
|