jenkins-maestrodev 0.6.9
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/Changelog.md +58 -0
- data/Gemfile +3 -0
- data/README.md +162 -0
- data/Rakefile +110 -0
- data/bin/jenkins +9 -0
- data/cucumber.yml +8 -0
- data/features/build_details.feature +44 -0
- data/features/configure.feature +36 -0
- data/features/default_host.feature +26 -0
- data/features/development.feature +14 -0
- data/features/listing_jobs.feature +34 -0
- data/features/manage_jobs.feature +263 -0
- data/features/manage_slave_nodes.feature +83 -0
- data/features/step_definitions/common_steps.rb +192 -0
- data/features/step_definitions/fixture_project_steps.rb +8 -0
- data/features/step_definitions/jenkins_steps.rb +116 -0
- data/features/step_definitions/scm_steps.rb +12 -0
- data/features/support/common.rb +37 -0
- data/features/support/env.rb +19 -0
- data/features/support/hooks.rb +16 -0
- data/features/support/jenkins_helpers.rb +6 -0
- data/features/support/matchers.rb +10 -0
- data/fixtures/jenkins/envfile.hpi +0 -0
- data/fixtures/jenkins/git.hpi +0 -0
- data/fixtures/jenkins/github.hpi +0 -0
- data/fixtures/jenkins/greenballs.hpi +0 -0
- data/fixtures/jenkins/rake.hpi +0 -0
- data/fixtures/jenkins/ruby.hpi +0 -0
- data/fixtures/projects/erlang/rebar.config +1 -0
- data/fixtures/projects/non-bundler/Rakefile +4 -0
- data/fixtures/projects/rails-3/.gitignore +4 -0
- data/fixtures/projects/rails-3/Gemfile +30 -0
- data/fixtures/projects/rails-3/Gemfile.lock +74 -0
- data/fixtures/projects/rails-3/README +256 -0
- data/fixtures/projects/rails-3/Rakefile +7 -0
- data/fixtures/projects/rails-3/app/controllers/application_controller.rb +3 -0
- data/fixtures/projects/rails-3/app/helpers/application_helper.rb +2 -0
- data/fixtures/projects/rails-3/app/views/layouts/application.html.erb +14 -0
- data/fixtures/projects/rails-3/config.ru +4 -0
- data/fixtures/projects/rails-3/config/application.rb +42 -0
- data/fixtures/projects/rails-3/config/boot.rb +13 -0
- data/fixtures/projects/rails-3/config/database.yml +22 -0
- data/fixtures/projects/rails-3/config/environment.rb +5 -0
- data/fixtures/projects/rails-3/config/environments/development.rb +26 -0
- data/fixtures/projects/rails-3/config/environments/production.rb +49 -0
- data/fixtures/projects/rails-3/config/environments/test.rb +35 -0
- data/fixtures/projects/rails-3/config/initializers/backtrace_silencers.rb +7 -0
- data/fixtures/projects/rails-3/config/initializers/inflections.rb +10 -0
- data/fixtures/projects/rails-3/config/initializers/mime_types.rb +5 -0
- data/fixtures/projects/rails-3/config/initializers/secret_token.rb +7 -0
- data/fixtures/projects/rails-3/config/initializers/session_store.rb +8 -0
- data/fixtures/projects/rails-3/config/locales/en.yml +5 -0
- data/fixtures/projects/rails-3/config/routes.rb +58 -0
- data/fixtures/projects/rails-3/db/seeds.rb +7 -0
- data/fixtures/projects/rails-3/doc/README_FOR_APP +2 -0
- data/fixtures/projects/rails-3/lib/tasks/.gitkeep +0 -0
- data/fixtures/projects/rails-3/public/404.html +26 -0
- data/fixtures/projects/rails-3/public/422.html +26 -0
- data/fixtures/projects/rails-3/public/500.html +26 -0
- data/fixtures/projects/rails-3/public/favicon.ico +0 -0
- data/fixtures/projects/rails-3/public/images/rails.png +0 -0
- data/fixtures/projects/rails-3/public/index.html +239 -0
- data/fixtures/projects/rails-3/public/javascripts/application.js +2 -0
- data/fixtures/projects/rails-3/public/javascripts/controls.js +965 -0
- data/fixtures/projects/rails-3/public/javascripts/dragdrop.js +974 -0
- data/fixtures/projects/rails-3/public/javascripts/effects.js +1123 -0
- data/fixtures/projects/rails-3/public/javascripts/prototype.js +6001 -0
- data/fixtures/projects/rails-3/public/javascripts/rails.js +175 -0
- data/fixtures/projects/rails-3/public/robots.txt +5 -0
- data/fixtures/projects/rails-3/public/stylesheets/.gitkeep +0 -0
- data/fixtures/projects/rails-3/script/rails +6 -0
- data/fixtures/projects/rails-3/test/performance/browsing_test.rb +9 -0
- data/fixtures/projects/rails-3/test/test_helper.rb +13 -0
- data/fixtures/projects/rails-3/vendor/plugins/.gitkeep +0 -0
- data/fixtures/projects/ruby/Gemfile +3 -0
- data/fixtures/projects/ruby/Gemfile.lock +10 -0
- data/fixtures/projects/ruby/Rakefile +4 -0
- data/jenkins.gemspec +34 -0
- data/lib/jenkins.rb +6 -0
- data/lib/jenkins/api.rb +312 -0
- data/lib/jenkins/cli.rb +361 -0
- data/lib/jenkins/cli/formatting.rb +53 -0
- data/lib/jenkins/config.rb +27 -0
- data/lib/jenkins/core_ext/hash.rb +9 -0
- data/lib/jenkins/core_ext/object/blank.rb +77 -0
- data/lib/jenkins/hudson-cli.jar +0 -0
- data/lib/jenkins/job_config_builder.rb +417 -0
- data/lib/jenkins/project_scm.rb +22 -0
- data/lib/jenkins/remote.rb +11 -0
- data/lib/jenkins/version.rb +3 -0
- data/spec/api_spec.rb +67 -0
- data/spec/fixtures/ec2_global.config.xml +103 -0
- data/spec/fixtures/erlang.single.config.xml +59 -0
- data/spec/fixtures/rails.multi.config.xml +82 -0
- data/spec/fixtures/rails.single.config.triggers.xml +84 -0
- data/spec/fixtures/rails.single.config.xml +80 -0
- data/spec/fixtures/ruby.multi-ruby-multi-labels.config.xml +84 -0
- data/spec/fixtures/ruby.multi.config.xml +77 -0
- data/spec/fixtures/ruby.single.config.xml +58 -0
- data/spec/fixtures/ruby.user-defined-axis.config.xml +69 -0
- data/spec/fixtures/therubyracer.config.xml +77 -0
- data/spec/hash_key_cleaner_spec.rb +25 -0
- data/spec/job_config_builder_spec.rb +233 -0
- data/spec/spec_helper.rb +15 -0
- metadata +291 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Vendored from activesupport 3.0.1
|
|
2
|
+
class Object
|
|
3
|
+
# An object is blank if it's false, empty, or a whitespace string.
|
|
4
|
+
# For example, "", " ", +nil+, [], and {} are blank.
|
|
5
|
+
#
|
|
6
|
+
# This simplifies:
|
|
7
|
+
#
|
|
8
|
+
# if !address.nil? && !address.empty?
|
|
9
|
+
#
|
|
10
|
+
# ...to:
|
|
11
|
+
#
|
|
12
|
+
# if !address.blank?
|
|
13
|
+
def blank?
|
|
14
|
+
respond_to?(:empty?) ? empty? : !self
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# An object is present if it's not blank.
|
|
18
|
+
def present?
|
|
19
|
+
!blank?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Returns object if it's #present? otherwise returns nil.
|
|
23
|
+
# object.presence is equivalent to object.present? ? object : nil.
|
|
24
|
+
#
|
|
25
|
+
# This is handy for any representation of objects where blank is the same
|
|
26
|
+
# as not present at all. For example, this simplifies a common check for
|
|
27
|
+
# HTTP POST/query parameters:
|
|
28
|
+
#
|
|
29
|
+
# state = params[:state] if params[:state].present?
|
|
30
|
+
# country = params[:country] if params[:country].present?
|
|
31
|
+
# region = state || country || 'US'
|
|
32
|
+
#
|
|
33
|
+
# ...becomes:
|
|
34
|
+
#
|
|
35
|
+
# region = params[:state].presence || params[:country].presence || 'US'
|
|
36
|
+
def presence
|
|
37
|
+
self if present?
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class NilClass #:nodoc:
|
|
42
|
+
def blank?
|
|
43
|
+
true
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class FalseClass #:nodoc:
|
|
48
|
+
def blank?
|
|
49
|
+
true
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class TrueClass #:nodoc:
|
|
54
|
+
def blank?
|
|
55
|
+
false
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class Array #:nodoc:
|
|
60
|
+
alias_method :blank?, :empty?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class Hash #:nodoc:
|
|
64
|
+
alias_method :blank?, :empty?
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class String #:nodoc:
|
|
68
|
+
def blank?
|
|
69
|
+
self !~ /\S/
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class Numeric #:nodoc:
|
|
74
|
+
def blank?
|
|
75
|
+
false
|
|
76
|
+
end
|
|
77
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
require "builder"
|
|
2
|
+
|
|
3
|
+
module Jenkins
|
|
4
|
+
class JobConfigBuilder
|
|
5
|
+
attr_accessor :job_type
|
|
6
|
+
attr_accessor :steps, :rubies, :user_axes
|
|
7
|
+
attr_accessor :triggers
|
|
8
|
+
attr_accessor :publishers
|
|
9
|
+
attr_accessor :log_rotate
|
|
10
|
+
attr_accessor :scm, :public_scm, :scm_branches
|
|
11
|
+
attr_accessor :assigned_node, :node_labels # TODO just one of these
|
|
12
|
+
attr_accessor :envfile
|
|
13
|
+
|
|
14
|
+
InvalidTemplate = Class.new(StandardError)
|
|
15
|
+
|
|
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
|
+
}
|
|
22
|
+
|
|
23
|
+
# +job_type+ - template of default steps to create with the job
|
|
24
|
+
# +steps+ - array of [:method, cmd], e.g. [:build_shell_step, "bundle initial"]
|
|
25
|
+
# - Default is based on +job_type+.
|
|
26
|
+
# +scm+ - URL to the repository. Currently only support git URLs.
|
|
27
|
+
# +public_scm+ - convert the +scm+ URL to a publicly accessible URL for the Jenkins job config.
|
|
28
|
+
# +scm_branches+ - array of branches to run builds. Default: ['master']
|
|
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
|
|
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
|
|
34
|
+
def initialize(job_type = :ruby, &block)
|
|
35
|
+
self.job_type = job_type.to_s if job_type
|
|
36
|
+
|
|
37
|
+
yield self
|
|
38
|
+
|
|
39
|
+
self.scm_branches ||= ["master"]
|
|
40
|
+
raise InvalidTemplate unless VALID_JOB_TEMPLATES.include?(job_type.to_s)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def builder
|
|
44
|
+
b = Builder::XmlMarkup.new :indent => 2
|
|
45
|
+
b.instruct!
|
|
46
|
+
b.tag!(matrix_project? ? "matrix-project" : "project") do
|
|
47
|
+
b.actions
|
|
48
|
+
b.description
|
|
49
|
+
build_log_rotator b
|
|
50
|
+
b.keepDependencies false
|
|
51
|
+
b.properties
|
|
52
|
+
build_scm b
|
|
53
|
+
b.assignedNode assigned_node if assigned_node
|
|
54
|
+
b.canRoam !assigned_node
|
|
55
|
+
b.disabled false
|
|
56
|
+
b.blockBuildWhenUpstreamBuilding false
|
|
57
|
+
build_triggers b
|
|
58
|
+
b.concurrentBuild false
|
|
59
|
+
build_axes b if matrix_project?
|
|
60
|
+
build_steps b
|
|
61
|
+
build_publishers b
|
|
62
|
+
build_wrappers b
|
|
63
|
+
b.runSequentially false if matrix_project?
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def to_xml
|
|
68
|
+
builder.to_s
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
protected
|
|
72
|
+
|
|
73
|
+
# <scm class="hudson.plugins.git.GitSCM"> ... </scm>
|
|
74
|
+
def build_scm(b)
|
|
75
|
+
if scm && scm =~ /git/
|
|
76
|
+
scm_url = public_scm ? public_only_git_scm(scm) : scm
|
|
77
|
+
b.scm :class => "hudson.plugins.git.GitSCM" do
|
|
78
|
+
b.configVersion 1
|
|
79
|
+
b.remoteRepositories do
|
|
80
|
+
b.tag! "org.spearce.jgit.transport.RemoteConfig" do
|
|
81
|
+
b.string "origin"
|
|
82
|
+
b.int 5
|
|
83
|
+
b.string "fetch"
|
|
84
|
+
b.string "+refs/heads/*:refs/remotes/origin/*"
|
|
85
|
+
b.string "receivepack"
|
|
86
|
+
b.string "git-upload-pack"
|
|
87
|
+
b.string "uploadpack"
|
|
88
|
+
b.string "git-upload-pack"
|
|
89
|
+
b.string "url"
|
|
90
|
+
b.string scm_url
|
|
91
|
+
b.string "tagopt"
|
|
92
|
+
b.string
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
if scm_branches
|
|
97
|
+
b.branches do
|
|
98
|
+
scm_branches.each do |branch|
|
|
99
|
+
b.tag! "hudson.plugins.git.BranchSpec" do
|
|
100
|
+
b.name branch
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
b.localBranch
|
|
107
|
+
b.mergeOptions
|
|
108
|
+
b.recursiveSubmodules false
|
|
109
|
+
b.doGenerateSubmoduleConfigurations false
|
|
110
|
+
b.authorOrCommitter false
|
|
111
|
+
b.clean false
|
|
112
|
+
b.wipeOutWorkspace false
|
|
113
|
+
b.buildChooser :class => "hudson.plugins.git.util.DefaultBuildChooser"
|
|
114
|
+
b.gitTool "Default"
|
|
115
|
+
b.submoduleCfg :class => "list"
|
|
116
|
+
b.relativeTargetDir
|
|
117
|
+
b.excludedRegions
|
|
118
|
+
b.excludedUsers
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def matrix_project?
|
|
124
|
+
!(rubies.blank? && node_labels.blank? && user_axes.blank?)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
#<hudson.matrix.TextAxis>
|
|
128
|
+
# <name>user_defined_axis</name>
|
|
129
|
+
# <values>
|
|
130
|
+
# <string>custom_value_1</string>
|
|
131
|
+
# <string>custom_value_2</string>
|
|
132
|
+
# <string>custom_value_3</string>
|
|
133
|
+
# </values>
|
|
134
|
+
# </hudson.matrix.TextAxis>
|
|
135
|
+
# <hudson.matrix.TextAxis>
|
|
136
|
+
# <name>RUBY_VERSION</name>
|
|
137
|
+
# <values>
|
|
138
|
+
# <string>1.8.7</string>
|
|
139
|
+
# <string>1.9.2</string>
|
|
140
|
+
# <string>rbx-head</string>
|
|
141
|
+
# <string>jruby</string>
|
|
142
|
+
# </values>
|
|
143
|
+
# </hudson.matrix.TextAxis>
|
|
144
|
+
# <hudson.matrix.LabelAxis>
|
|
145
|
+
# <name>label</name>
|
|
146
|
+
# <values>
|
|
147
|
+
# <string>1.8.7</string>
|
|
148
|
+
# <string>ubuntu</string>
|
|
149
|
+
# </values>
|
|
150
|
+
# </hudson.matrix.LabelAxis>
|
|
151
|
+
def build_axes(b)
|
|
152
|
+
b.axes do
|
|
153
|
+
unless user_axes.blank?
|
|
154
|
+
user_axes.each do |axis|
|
|
155
|
+
b.tag! "hudson.matrix.TextAxis" do
|
|
156
|
+
b.name axis[:name]
|
|
157
|
+
b.values do
|
|
158
|
+
axis[:values].each do |value|
|
|
159
|
+
b.string value
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
unless rubies.blank?
|
|
166
|
+
b.tag! "hudson.matrix.TextAxis" do
|
|
167
|
+
b.name "RUBY_VERSION"
|
|
168
|
+
b.values do
|
|
169
|
+
rubies.each do |rvm_name|
|
|
170
|
+
b.string rvm_name
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
unless node_labels.blank?
|
|
176
|
+
b.tag! "hudson.matrix.LabelAxis" do
|
|
177
|
+
b.name "label"
|
|
178
|
+
b.values do
|
|
179
|
+
node_labels.each do |label|
|
|
180
|
+
b.string label
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Example:
|
|
189
|
+
# <buildWrappers>
|
|
190
|
+
# <hudson.plugins.envfile.EnvFileBuildWrapper>
|
|
191
|
+
# <filePath>/path/to/env/file</filePath>
|
|
192
|
+
# </hudson.plugins.envfile.EnvFileBuildWrapper>
|
|
193
|
+
# </buildWrappers>
|
|
194
|
+
def build_wrappers(b)
|
|
195
|
+
if envfile
|
|
196
|
+
b.buildWrappers do
|
|
197
|
+
self.envfile = [envfile] unless envfile.is_a?(Array)
|
|
198
|
+
b.tag! "hudson.plugins.envfile.EnvFileBuildWrapper" do
|
|
199
|
+
envfile.each do |file|
|
|
200
|
+
b.filePath file
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
else
|
|
205
|
+
b.buildWrappers
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Example
|
|
210
|
+
# <triggers class="vector">
|
|
211
|
+
# <hudson.triggers.TimerTrigger>
|
|
212
|
+
# <spec>* * * * *</spec>
|
|
213
|
+
# </hudson.triggers.TimerTrigger>
|
|
214
|
+
# </triggers>
|
|
215
|
+
def build_triggers(b)
|
|
216
|
+
if triggers
|
|
217
|
+
b.triggers :class => "vector" do
|
|
218
|
+
triggers.each do |trigger|
|
|
219
|
+
case trigger[:class]
|
|
220
|
+
when :timer
|
|
221
|
+
b.tag! "hudson.triggers.TimerTrigger" do
|
|
222
|
+
b.spec trigger[:spec]
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
else
|
|
228
|
+
b.triggers :class => "vector"
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Example
|
|
233
|
+
# <logRotator>
|
|
234
|
+
# <daysToKeep>14</daysToKeep>
|
|
235
|
+
# <numToKeep>-1</numToKeep>
|
|
236
|
+
# <artifactDaysToKeep>-1</artifactDaysToKeep>
|
|
237
|
+
# <artifactNumToKeep>-1</artifactNumToKeep>
|
|
238
|
+
# </logRotator>
|
|
239
|
+
def build_log_rotator(b)
|
|
240
|
+
if log_rotate
|
|
241
|
+
b.logRotator do
|
|
242
|
+
b.daysToKeep log_rotate[:days_to_keep] || -1
|
|
243
|
+
b.numToKeep log_rotate[:num_to_keep] || -1
|
|
244
|
+
b.artifactDaysToKeep log_rotate[:artifact_days_to_keep] || -1
|
|
245
|
+
b.artifactNumToKeep log_rotate[:artifact_num_to_keep] || -1
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Example
|
|
251
|
+
# <publishers>
|
|
252
|
+
# <hudson.plugins.chucknorris.CordellWalkerRecorder>
|
|
253
|
+
# <factGenerator/>
|
|
254
|
+
# </hudson.plugins.chucknorris.CordellWalkerRecorder>
|
|
255
|
+
# <hudson.tasks.BuildTrigger>
|
|
256
|
+
# <childProjects>Dependent Job, Even more dependent job</childProjects>
|
|
257
|
+
# <threshold>
|
|
258
|
+
# <name>SUCCESS</name>
|
|
259
|
+
# <ordinal>0</ordinal>
|
|
260
|
+
# <color>BLUE</color>
|
|
261
|
+
# </threshold>
|
|
262
|
+
# </hudson.tasks.BuildTrigger>
|
|
263
|
+
# <hudson.tasks.Mailer>
|
|
264
|
+
# <recipients>some.guy@example.com, another.guy@example.com</recipients>
|
|
265
|
+
# <dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
|
|
266
|
+
# <sendToIndividuals>true</sendToIndividuals>
|
|
267
|
+
# </hudson.tasks.Mailer>
|
|
268
|
+
# </publishers>
|
|
269
|
+
def build_publishers(b)
|
|
270
|
+
if publishers
|
|
271
|
+
b.publishers do
|
|
272
|
+
publishers.each do |publisher|
|
|
273
|
+
publisher_name, params = publisher.to_a.first
|
|
274
|
+
case publisher_name
|
|
275
|
+
when :mailer
|
|
276
|
+
b.tag! "hudson.tasks.Mailer" do
|
|
277
|
+
b.recipients params.join(', ')
|
|
278
|
+
b.dontNotifyEveryUnstableBuild false
|
|
279
|
+
b.sendToIndividuals true
|
|
280
|
+
end
|
|
281
|
+
when :job_triggers
|
|
282
|
+
b.tag! "hudson.tasks.BuildTrigger" do
|
|
283
|
+
b.childProjects params[:projects].join(', ')
|
|
284
|
+
b.threshold do
|
|
285
|
+
trigger_event = params[:on] || "SUCCESS"
|
|
286
|
+
b.name trigger_event
|
|
287
|
+
b.ordinal JOB_TRIGGER_THRESHOLDS[trigger_event][:ordinal]
|
|
288
|
+
b.color JOB_TRIGGER_THRESHOLDS[trigger_event][:color]
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
when :chuck_norris
|
|
292
|
+
b.tag! "hudson.plugins.chucknorris.CordellWalkerRecorder" do
|
|
293
|
+
b.factGenerator
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
else
|
|
299
|
+
b.publishers
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# The important sequence of steps that are run to process a job build.
|
|
304
|
+
# Can be defaulted by the +job_type+ using +default_steps(job_type)+,
|
|
305
|
+
# or customized via +steps+ array.
|
|
306
|
+
def build_steps(b)
|
|
307
|
+
b.builders do
|
|
308
|
+
self.steps ||= default_steps(job_type)
|
|
309
|
+
steps.each do |step|
|
|
310
|
+
method, cmd = step
|
|
311
|
+
send(method.to_sym, b, cmd) # e.g. build_shell_step(b, "bundle install")
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def default_steps(job_type)
|
|
317
|
+
steps = case job_type.to_sym
|
|
318
|
+
when :rails, :rails3
|
|
319
|
+
[
|
|
320
|
+
[:build_shell_step, "bundle install"],
|
|
321
|
+
[:build_ruby_step, <<-RUBY.gsub(/^ /, '')],
|
|
322
|
+
unless File.exist?("config/database.yml")
|
|
323
|
+
require 'fileutils'
|
|
324
|
+
example = Dir["config/database*"].first
|
|
325
|
+
puts "Using \#{example} for config/database.yml"
|
|
326
|
+
FileUtils.cp example, "config/database.yml"
|
|
327
|
+
end
|
|
328
|
+
RUBY
|
|
329
|
+
[:build_shell_step, "bundle exec rake db:create:all"],
|
|
330
|
+
[:build_shell_step, <<-RUBY.gsub(/^ /, '')],
|
|
331
|
+
if [ -f db/schema.rb ]; then
|
|
332
|
+
bundle exec rake db:schema:load
|
|
333
|
+
else
|
|
334
|
+
bundle exec rake db:migrate
|
|
335
|
+
fi
|
|
336
|
+
RUBY
|
|
337
|
+
[:build_shell_step, "bundle exec rake"]
|
|
338
|
+
]
|
|
339
|
+
when :ruby, :rubygems
|
|
340
|
+
[
|
|
341
|
+
[:build_shell_step, "bundle install"],
|
|
342
|
+
[:build_shell_step, "bundle exec rake"]
|
|
343
|
+
]
|
|
344
|
+
when :erlang
|
|
345
|
+
[
|
|
346
|
+
[:build_shell_step, "rebar compile"],
|
|
347
|
+
[:build_shell_step, "rebar ct"]
|
|
348
|
+
]
|
|
349
|
+
else
|
|
350
|
+
[ [:build_shell_step, 'echo "THERE ARE NO STEPS! Except this one..."'] ]
|
|
351
|
+
end
|
|
352
|
+
rubies.blank? ? steps : default_rvm_steps + steps
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
def default_rvm_steps
|
|
356
|
+
[
|
|
357
|
+
[:build_shell_step, "rvm $RUBY_VERSION"],
|
|
358
|
+
[:build_shell_step, "rvm gemset create ruby-$RUBY_VERSION && rvm gemset use ruby-$RUBY_VERSION"]
|
|
359
|
+
]
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
# <hudson.tasks.Shell>
|
|
363
|
+
# <command>echo 'THERE ARE NO STEPS! Except this one...'</command>
|
|
364
|
+
# </hudson.tasks.Shell>
|
|
365
|
+
def build_shell_step(b, command)
|
|
366
|
+
b.tag! "hudson.tasks.Shell" do
|
|
367
|
+
b.command command.to_xs.gsub("&", '&') #.gsub(%r{"}, '"').gsub(%r{'}, ''')
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
# <hudson.plugins.ruby.Ruby>
|
|
372
|
+
# <command>unless File.exist?("config/database.yml")
|
|
373
|
+
# require 'fileutils'
|
|
374
|
+
# example = Dir["config/database*"].first
|
|
375
|
+
# puts "Using #{example} for config/database.yml"
|
|
376
|
+
# FileUtils.cp example, "config/database.yml"
|
|
377
|
+
# end</command>
|
|
378
|
+
# </hudson.plugins.ruby.Ruby>
|
|
379
|
+
def build_ruby_step(b, command)
|
|
380
|
+
b.tag! "hudson.plugins.ruby.Ruby" do
|
|
381
|
+
b.command do
|
|
382
|
+
b << command.to_xs.gsub(%r{"}, '"').gsub(%r{'}, ''')
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
# Usage: build_ruby_step b, "db:schema:load"
|
|
388
|
+
#
|
|
389
|
+
# <hudson.plugins.rake.Rake>
|
|
390
|
+
# <rakeInstallation>(Default)</rakeInstallation>
|
|
391
|
+
# <rakeFile></rakeFile>
|
|
392
|
+
# <rakeLibDir></rakeLibDir>
|
|
393
|
+
# <rakeWorkingDir></rakeWorkingDir>
|
|
394
|
+
# <tasks>db:schema:load</tasks>
|
|
395
|
+
# <silent>false</silent>
|
|
396
|
+
# </hudson.plugins.rake.Rake>
|
|
397
|
+
def build_rake_step(b, tasks)
|
|
398
|
+
b.tag! "hudson.plugins.rake.Rake" do
|
|
399
|
+
b.rakeInstallation "(Default)"
|
|
400
|
+
b.rakeFile
|
|
401
|
+
b.rakeLibDir
|
|
402
|
+
b.rakeWorkingDir
|
|
403
|
+
b.tasks tasks
|
|
404
|
+
b.silent false
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# Converts git@github.com:drnic/newgem.git into git://github.com/drnic/newgem.git
|
|
409
|
+
def public_only_git_scm(scm_url)
|
|
410
|
+
if scm_url =~ /git@([\w\-_.]+):(.+)\.git/
|
|
411
|
+
"git://#{$1}/#{$2}.git"
|
|
412
|
+
else
|
|
413
|
+
scm_url
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
end
|