Class: Hudson::JobConfigBuilder
- Defined in:
- lib/hudson/job_config_builder.rb
Constant Summary collapse
- InvalidTemplate =
Class.new(StandardError)
- VALID_JOB_TEMPLATES =
%w[rails rails3 ruby rubygem]
Instance Attribute Summary collapse
-
#assigned_node ⇒ Object
Returns the value of attribute assigned_node.
-
#envfile ⇒ Object
Returns the value of attribute envfile.
-
#git_branches ⇒ Object
Returns the value of attribute git_branches.
-
#job_type ⇒ Object
Returns the value of attribute job_type.
-
#matrix_project ⇒ Object
Returns the value of attribute matrix_project.
-
#public_scm ⇒ Object
Returns the value of attribute public_scm.
-
#scm ⇒ Object
Returns the value of attribute scm.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
- #builder ⇒ Object
-
#initialize(job_type = :ruby) {|_self| ... } ⇒ JobConfigBuilder
constructor
job_type
- template of default steps to create with the jobsteps
- array of [:method, cmd], e.g. - #to_xml ⇒ Object
Constructor Details
#initialize(job_type = :ruby) {|_self| ... } ⇒ JobConfigBuilder
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’] assigned_node
- restrict this job to running on slaves with these labels (space separated)
22 23 24 25 26 27 28 29 |
# File 'lib/hudson/job_config_builder.rb', line 22 def initialize(job_type = :ruby, &block) self.job_type = job_type.to_s if job_type yield self self.git_branches ||= ["master"] raise InvalidTemplate unless VALID_JOB_TEMPLATES.include?(job_type.to_s) end |
Instance Attribute Details
#assigned_node ⇒ Object
Returns the value of attribute assigned_node.
8 9 10 |
# File 'lib/hudson/job_config_builder.rb', line 8 def assigned_node @assigned_node end |
#envfile ⇒ Object
Returns the value of attribute envfile.
9 10 11 |
# File 'lib/hudson/job_config_builder.rb', line 9 def envfile @envfile end |
#git_branches ⇒ Object
Returns the value of attribute git_branches.
7 8 9 |
# File 'lib/hudson/job_config_builder.rb', line 7 def git_branches @git_branches end |
#job_type ⇒ Object
Returns the value of attribute job_type.
5 6 7 |
# File 'lib/hudson/job_config_builder.rb', line 5 def job_type @job_type end |
#matrix_project ⇒ Object
Returns the value of attribute matrix_project.
5 6 7 |
# File 'lib/hudson/job_config_builder.rb', line 5 def matrix_project @matrix_project end |
#public_scm ⇒ Object
Returns the value of attribute public_scm.
7 8 9 |
# File 'lib/hudson/job_config_builder.rb', line 7 def public_scm @public_scm end |
#scm ⇒ Object
Returns the value of attribute scm.
7 8 9 |
# File 'lib/hudson/job_config_builder.rb', line 7 def scm @scm end |
#steps ⇒ Object
Returns the value of attribute steps.
6 7 8 |
# File 'lib/hudson/job_config_builder.rb', line 6 def steps @steps end |
Instance Method Details
#builder ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hudson/job_config_builder.rb', line 31 def builder b = Builder::XmlMarkup.new :indent => 2 b.instruct! b.tag!(matrix_project? ? "matrix-project" : "project") do b.actions b.description b.keepDependencies false b.properties build_scm b b.assignedNode assigned_node if assigned_node b.canRoam !assigned_node b.disabled false b.blockBuildWhenUpstreamBuilding false # build_triggers b b.concurrentBuild false build_axes b if matrix_project? build_steps b b.publishers build_wrappers b b.runSequentially false if matrix_project? end end |
#to_xml ⇒ Object
54 55 56 |
# File 'lib/hudson/job_config_builder.rb', line 54 def to_xml builder.to_s end |