Class: Hudson::XmlWriter::JobConfigInfo
- Inherits:
-
Object
- Object
- Hudson::XmlWriter::JobConfigInfo
- Defined in:
- lib/hudson-remote-api/xml_writer/job_config_info.rb
Constant Summary collapse
- SVN_SCM_CONF =
<<-SVN_SCM_STRING <scm class="hudson.scm.SubversionSCM"> <locations> <hudson.scm.SubversionSCM_-ModuleLocation> <remote>%s</remote> <local>.</local> </hudson.scm.SubversionSCM_-ModuleLocation> </locations> <excludedRegions/> <includedRegions/> <excludedUsers/> <excludedRevprop/> <excludedCommitMessages/> <workspaceUpdater class="hudson.scm.subversion.UpdateUpdater"/> </scm> SVN_SCM_STRING
Instance Attribute Summary collapse
-
#job_name ⇒ Object
Returns the value of attribute job_name.
-
#xml_doc ⇒ Object
Returns the value of attribute xml_doc.
Instance Method Summary collapse
- #description=(description) ⇒ Object
- #git_repository_browser_location=(repository_browser_location) ⇒ Object
- #git_repository_url=(repository_url) ⇒ Object
-
#initialize(job_name, raw_xml) ⇒ JobConfigInfo
constructor
A new instance of JobConfigInfo.
- #repository_urls=(repository_urls) ⇒ Object
- #svn_repository_browser_location=(repository_browser_location) ⇒ Object
- #svn_repository_url=(repository_url) ⇒ Object
- #triggers=(opts = {}) ⇒ Object
Constructor Details
#initialize(job_name, raw_xml) ⇒ JobConfigInfo
Returns a new instance of JobConfigInfo.
24 25 26 27 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 24 def initialize(job_name, raw_xml) @job_name = job_name @xml_doc = REXML::Document.new(raw_xml) end |
Instance Attribute Details
#job_name ⇒ Object
Returns the value of attribute job_name.
5 6 7 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 5 def job_name @job_name end |
#xml_doc ⇒ Object
Returns the value of attribute xml_doc.
5 6 7 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 5 def xml_doc @xml_doc end |
Instance Method Details
#description=(description) ⇒ Object
69 70 71 72 73 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 69 def description=(description) self.xml_doc.elements["/project"] << REXML::Element.new("description") if self.xml_doc.elements["/project/description"].nil? self.xml_doc.elements["/project/description"].text = description update end |
#git_repository_browser_location=(repository_browser_location) ⇒ Object
59 60 61 62 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 59 def git_repository_browser_location=(repository_browser_location) self.xml_doc.elements['/project/scm/browser/url'].text = repository_browser_location update end |
#git_repository_url=(repository_url) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 29 def git_repository_url=(repository_url) if repository_url[:url] self.xml_doc.elements['/project/scm/userRemoteConfigs/hudson.plugins.git.UserRemoteConfig/url'].text = repository_url[:url] end if repository_url[:branch] self.xml_doc.elements['/project/scm/branches/hudson.plugins.git.BranchSpec/name'].text = repository_url[:branch] end update end |
#repository_urls=(repository_urls) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 48 def repository_urls=(repository_urls) return false if !repository_urls.class == Array i = 0 self.xml_doc.elements.each("/project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation") do |location| location.elements["remote"].text = repository_urls[i] i += 1 end update end |
#svn_repository_browser_location=(repository_browser_location) ⇒ Object
64 65 66 67 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 64 def svn_repository_browser_location=(repository_browser_location) self.xml_doc.elements["/project/scm/browser/location"].text = repository_browser_location update end |
#svn_repository_url=(repository_url) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 39 def svn_repository_url=(repository_url) if self.xml_doc.elements["/project/scm"].attributes['class'] == "hudson.scm.NullSCM" self.xml_doc.elements["/project/scm"].replace_with REXML::Document.new(SVN_SCM_CONF % repository_url) else self.xml_doc.elements["/project/scm/locations/hudson.scm.SubversionSCM_-ModuleLocation/remote"].text = repository_url end update end |
#triggers=(opts = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/hudson-remote-api/xml_writer/job_config_info.rb', line 75 def triggers= opts={} opts = {} if opts.nil? if triggers = self.xml_doc.elements["/project/triggers"] || self.xml_doc.elements["/project/triggers[@class='vector']"] triggers.elements.delete_all '*' opts.each do |key, value| trigger_name = key.to_s trigger_name = 'hudson.triggers.' + trigger_name unless Regexp.new(/^hudson\.triggers\./).match(trigger_name) if trigger = triggers.elements[trigger_name] if spec = trigger.elements['spec'] spec.text = value.to_s else triggers.elements << generate_trigger(trigger, value) end else triggers.elements << generate_trigger(REXML::Element.new(trigger_name), value) end end update else $stderr.puts "triggers not found in configuration, triggers assignment ignored." end end |