Class: Jenkins::JobConfigBuilder
- Defined in:
- lib/jenkins/job_config_builder.rb
Constant Summary collapse
- InvalidTemplate =
Class.new(StandardError)
- VALID_JOB_TEMPLATES =
%w[none rails rails3 ruby rubygem erlang]
Instance Attribute Summary collapse
-
#assigned_node ⇒ Object
TODO just one of these.
-
#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.
-
#node_labels ⇒ Object
TODO just one of these.
-
#public_scm ⇒ Object
Returns the value of attribute public_scm.
-
#rubies ⇒ Object
Returns the value of attribute rubies.
-
#scm ⇒ Object
Returns the value of attribute scm.
-
#scm_branches ⇒ Object
Returns the value of attribute scm_branches.
-
#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 Jenkins job config. scm_branches
- array of branches to run builds. Default: [‘master’] rubies
- list of RVM rubies to run tests (via Jenkins Axes). assigned_node
- restrict this job to running on slaves with these labels (space separated)
24 25 26 27 28 29 30 31 |
# File 'lib/jenkins/job_config_builder.rb', line 24 def initialize(job_type = :ruby, &block) self.job_type = job_type.to_s if job_type yield self self.scm_branches ||= ["master"] raise InvalidTemplate unless VALID_JOB_TEMPLATES.include?(job_type.to_s) end |
Instance Attribute Details
#assigned_node ⇒ Object
TODO just one of these
9 10 11 |
# File 'lib/jenkins/job_config_builder.rb', line 9 def assigned_node @assigned_node end |
#envfile ⇒ Object
Returns the value of attribute envfile.
10 11 12 |
# File 'lib/jenkins/job_config_builder.rb', line 10 def envfile @envfile end |
#git_branches ⇒ Object
Returns the value of attribute git_branches.
8 9 10 |
# File 'lib/jenkins/job_config_builder.rb', line 8 def git_branches @git_branches end |
#job_type ⇒ Object
Returns the value of attribute job_type.
5 6 7 |
# File 'lib/jenkins/job_config_builder.rb', line 5 def job_type @job_type end |
#node_labels ⇒ Object
TODO just one of these
9 10 11 |
# File 'lib/jenkins/job_config_builder.rb', line 9 def node_labels @node_labels end |
#public_scm ⇒ Object
Returns the value of attribute public_scm.
7 8 9 |
# File 'lib/jenkins/job_config_builder.rb', line 7 def public_scm @public_scm end |
#rubies ⇒ Object
Returns the value of attribute rubies.
6 7 8 |
# File 'lib/jenkins/job_config_builder.rb', line 6 def rubies @rubies end |
#scm ⇒ Object
Returns the value of attribute scm.
7 8 9 |
# File 'lib/jenkins/job_config_builder.rb', line 7 def scm @scm end |
#scm_branches ⇒ Object
Returns the value of attribute scm_branches.
7 8 9 |
# File 'lib/jenkins/job_config_builder.rb', line 7 def scm_branches @scm_branches end |
#steps ⇒ Object
Returns the value of attribute steps.
6 7 8 |
# File 'lib/jenkins/job_config_builder.rb', line 6 def steps @steps end |
Instance Method Details
#builder ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/jenkins/job_config_builder.rb', line 33 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 b.triggers :class => "vector" 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
56 57 58 |
# File 'lib/jenkins/job_config_builder.rb', line 56 def to_xml builder.to_s end |