lib/hudson/job_config_builder.rb in hudson-0.3.0.beta.15 vs lib/hudson/job_config_builder.rb in hudson-0.3.0.beta.16
- old
+ new
@@ -2,22 +2,22 @@
module Hudson
class JobConfigBuilder
attr_accessor :job_type, :matrix_project
attr_accessor :steps
- attr_accessor :scm, :public_scm, :git_branches, :git_tool
+ attr_accessor :scm, :public_scm, :git_branches
attr_accessor :assigned_node
+ attr_accessor :envfile
InvalidTemplate = Class.new(StandardError)
# +job_type+ - template of default steps to create with the job
# +steps+ - array of [:method, cmd], e.g. [:build_shell_step, "bundle initial"]
# - Default is based on +job_type+.
# +scm+ - URL to the repository. Currently only support git URLs.
# +public_scm+ - convert the +scm+ URL to a publicly accessible URL for the Hudson job config.
# +git_branches+ - array of branches to run builds. Default: ['master']
- # +git_tool+ - key reference for Hudson CI git command. Default: 'Default'
# +assigned_node+ - restrict this job to running on slaves with these labels (space separated)
def initialize(job_type = :ruby, &block)
self.job_type = job_type.to_s if job_type
yield self
@@ -41,11 +41,11 @@
# build_triggers b
b.concurrentBuild false
build_axes b if matrix_project?
build_steps b
b.publishers
- b.buildWrappers
+ build_wrappers b
b.runSequentially false if matrix_project?
end
end
def to_xml
@@ -98,11 +98,11 @@
b.doGenerateSubmoduleConfigurations false
b.authorOrCommitter false
b.clean false
b.wipeOutWorkspace false
b.buildChooser :class => "hudson.plugins.git.util.DefaultBuildChooser"
- b.gitTool git_tool ? git_tool : "Default"
+ b.gitTool "Default"
b.submoduleCfg :class => "list"
b.relativeTargetDir
b.excludedRegions
b.excludedUsers
end
@@ -124,9 +124,30 @@
end
# TODO
def build_axes(b)
b.axes
+ end
+
+ # Example:
+ # <buildWrappers>
+ # <hudson.plugins.envfile.EnvFileBuildWrapper>
+ # <filePath>/path/to/env/file</filePath>
+ # </hudson.plugins.envfile.EnvFileBuildWrapper>
+ # </buildWrappers>
+ def build_wrappers(b)
+ if envfile
+ b.buildWrappers do
+ self.envfile = [envfile] unless envfile.is_a?(Array)
+ b.tag! "hudson.plugins.envfile.EnvFileBuildWrapper" do
+ envfile.each do |file|
+ b.filePath file
+ end
+ end
+ end
+ else
+ b.buildWrappers
+ end
end
# TODO modularise this
# TODO how to customize? e.g. EngineYard template?
VALID_JOB_TEMPLATES = %w[rails rails3 ruby rubygem]
\ No newline at end of file