Class: DynportTools::Jenkins::Project
- Inherits:
-
Object
- Object
- DynportTools::Jenkins::Project
- Defined in:
- lib/dynport_tools/jenkins/project.rb
Constant Summary collapse
- DEFAULT_SCM =
"hudson.scm.NullSCM"
- GIT_SCM =
"hudson.plugins.git.GitSCM"
Instance Attribute Summary collapse
-
#child_projects ⇒ Object
Returns the value of attribute child_projects.
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#crontab_pattern ⇒ Object
Returns the value of attribute crontab_pattern.
-
#days_to_keep ⇒ Object
Returns the value of attribute days_to_keep.
-
#delete ⇒ Object
Returns the value of attribute delete.
-
#description ⇒ Object
Returns the value of attribute description.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#email_addresses ⇒ Object
Returns the value of attribute email_addresses.
-
#git_repository ⇒ Object
Returns the value of attribute git_repository.
-
#locks ⇒ Object
Returns the value of attribute locks.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node ⇒ Object
Returns the value of attribute node.
-
#num_to_keep ⇒ Object
Returns the value of attribute num_to_keep.
Instance Method Summary collapse
- #deleted? ⇒ Boolean
- #git_options_xml(xml) ⇒ Object
- #git_repository_xml(xml) ⇒ Object
- #git_xml(xml) ⇒ Object
-
#initialize(name = nil) ⇒ Project
constructor
A new instance of Project.
- #log_rotate_xml(node) ⇒ Object
- #md5 ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ Project
7 8 9 10 11 12 13 |
# File 'lib/dynport_tools/jenkins/project.rb', line 7 def initialize(name = nil) self.name = name self.commands = [] self.child_projects = [] self.email_addresses = [] self.locks = [] end |
Instance Attribute Details
#child_projects ⇒ Object
Returns the value of attribute child_projects.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def child_projects @child_projects end |
#commands ⇒ Object
Returns the value of attribute commands.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def commands @commands end |
#crontab_pattern ⇒ Object
Returns the value of attribute crontab_pattern.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def crontab_pattern @crontab_pattern end |
#days_to_keep ⇒ Object
Returns the value of attribute days_to_keep.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def days_to_keep @days_to_keep end |
#delete ⇒ Object
Returns the value of attribute delete.
3 4 5 |
# File 'lib/dynport_tools/jenkins/project.rb', line 3 def delete @delete end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/dynport_tools/jenkins/project.rb', line 3 def description @description end |
#disabled ⇒ Object
Returns the value of attribute disabled.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def disabled @disabled end |
#email_addresses ⇒ Object
Returns the value of attribute email_addresses.
3 4 5 |
# File 'lib/dynport_tools/jenkins/project.rb', line 3 def email_addresses @email_addresses end |
#git_repository ⇒ Object
Returns the value of attribute git_repository.
3 4 5 |
# File 'lib/dynport_tools/jenkins/project.rb', line 3 def git_repository @git_repository end |
#locks ⇒ Object
Returns the value of attribute locks.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def locks @locks end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def name @name end |
#node ⇒ Object
Returns the value of attribute node.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def node @node end |
#num_to_keep ⇒ Object
Returns the value of attribute num_to_keep.
2 3 4 |
# File 'lib/dynport_tools/jenkins/project.rb', line 2 def num_to_keep @num_to_keep end |
Instance Method Details
#deleted? ⇒ Boolean
15 16 17 |
# File 'lib/dynport_tools/jenkins/project.rb', line 15 def deleted? !!@delete end |
#git_options_xml(xml) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dynport_tools/jenkins/project.rb', line 49 def (xml) xml.mergeOptions xml.recursiveSubmodules false xml.doGenerateSubmoduleConfigurations false xml. false xml.clean false xml.wipeOutWorkspace false xml.pruneBranches false xml.buildChooser(:class => "hudson.plugins.git.util.DefaultBuildChooser") xml.gitTool "Default" xml.submoduleCfg(:class => "list") xml.relativeTargetDir xml.excludedRegion xml.excludedUsers xml.skipTag false end |
#git_repository_xml(xml) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dynport_tools/jenkins/project.rb', line 32 def git_repository_xml(xml) xml.send("org.spearce.jgit.transport.RemoteConfig") do xml.string "origin" xml.int 5 xml.string "fetch" xml.string "+refs/heads/*:refs/remotes/origin/*" xml.string "receivepack" xml.string "git-upload-pack" xml.string "uploadpack" xml.string "git-upload-pack" xml.string "url" xml.string git_repository xml.string "tagopt" xml.string end end |
#git_xml(xml) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/dynport_tools/jenkins/project.rb', line 66 def git_xml(xml) xml.scm(:class => GIT_SCM) do xml.config_version 1 xml.remoteRepositories do git_repository_xml(xml) end xml.branches do xml.send("hudson.plugins.git.BranchSpec") do xml.name "master" end end (xml) end end |
#log_rotate_xml(node) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/dynport_tools/jenkins/project.rb', line 23 def log_rotate_xml(node) node.logRotator do node.daysToKeep days_to_keep || -1 node.numToKeep num_to_keep || -1 node.artifactDaysToKeep -1 node.artifactNumToKeep -1 end end |
#md5 ⇒ Object
19 20 21 |
# File 'lib/dynport_tools/jenkins/project.rb', line 19 def md5 Digest::MD5.hexdigest(to_xml) end |
#to_xml ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/dynport_tools/jenkins/project.rb', line 81 def to_xml Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml| xml.project do xml.actions xml.description *[description].compact log_rotate_xml(xml) if days_to_keep || num_to_keep xml.keepDependencies false xml.properties if git_repository git_xml(xml) else xml.scm(:class => DEFAULT_SCM) end if node xml.assignedNode node xml.canRoam false else xml.canRoam true end xml.disabled disabled ? true : false xml.blockBuildWhenDownstreamBuilding false xml.blockBuildWhenUpstreamBuilding false xml.triggers(:class => "vector") do if crontab_pattern xml.send("hudson.triggers.TimerTrigger") do xml.spec crontab_pattern end end end xml.concurrentBuild false xml.builders do commands.each do |command| xml.send("hudson.tasks.Shell") do xml.command command end end end xml.publishers do if child_projects.any? xml.send("hudson.tasks.BuildTrigger") do xml.childProjects child_projects.map { |c| c.name }.join(",") xml.threshold do xml.name "SUCCESS" xml.ordinal "0" xml.color "BLUE" end end end if email_addresses.any? xml.send("hudson.tasks.Mailer") do xml.recipients email_addresses.join(",") xml.dontNotifyEveryUnstableBuild true xml.sendToIndividuals false end end end xml.buildWrappers do if locks.any? xml.send("hudson.plugins.locksandlatches.LockWrapper") do xml.locks do locks.each do |lock| xml.send("hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig") { xml.name lock } end end end end end end end.to_xml end |