Module: Cigale::Generator
- Included in:
- CLI
- Defined in:
- lib/cigale/generator.rb
Instance Method Summary collapse
- #insert_raw(xml, spec) ⇒ Object
- #method_for_translate(kind, type) ⇒ Object
-
#translate(kind, xml, type, spec) ⇒ Object
kind = ‘property’, ‘parameter’, ‘builder’ type = ‘scmpoll’, ‘github’, etc.
- #translate_flow_project(xml, jdef) ⇒ Object
- #translate_job(xml, jdef) ⇒ Object
- #translate_matrix_project(xml, jdef) ⇒ Object
- #translate_maven_moduleset(xml, jdef) ⇒ Object
Instance Method Details
#insert_raw(xml, spec) ⇒ Object
143 144 145 146 147 148 |
# File 'lib/cigale/generator.rb', line 143 def insert_raw (xml, spec) for l in spec["xml"].split("\n") xml.indent! xml << l + "\n" end end |
#method_for_translate(kind, type) ⇒ Object
139 140 141 |
# File 'lib/cigale/generator.rb', line 139 def method_for_translate (kind, type) "translate_#{underize(type)}_#{kind}" end |
#translate(kind, xml, type, spec) ⇒ Object
kind = ‘property’, ‘parameter’, ‘builder’ type = ‘scmpoll’, ‘github’, etc.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/cigale/generator.rb', line 114 def translate (kind, xml, type, spec) if type == "raw" return insert_raw xml, spec end classes = self.send "#{kind}_classes" clazz = classes[type] raise "Unknown #{kind} type: #{type}" unless clazz method = method_for_translate(kind, type) case clazz when String xml.tag! clazz do self.send method, xml, spec end when Array xml.tag! *clazz do self.send method, xml, spec end else self.send method, xml, spec end end |
#translate_flow_project(xml, jdef) ⇒ Object
294 295 296 297 |
# File 'lib/cigale/generator.rb', line 294 def translate_flow_project (xml, jdef) xml.dsl xml.buildNeedsWorkspace false end |
#translate_job(xml, jdef) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 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 |
# File 'lib/cigale/generator.rb', line 20 def translate_job (xml, jdef) type = jdef["project-type"] testcat = @opts[:test_category] project = case type when "matrix" "matrix-project" when "maven" "maven2-moduleset" when "flow" "com.cloudbees.plugins.flow.BuildFlow" when "multijob" "com.tikal.jenkins.plugins.multijob.MultiJobProject" when "externaljob" "hudson.model.ExternalJob" else "project" end xml.tag! project do case type when "matrix" translate_matrix_project xml, jdef when "maven" translate_maven_moduleset xml, jdef when "flow" translate_flow_project xml, jdef end # case project if testcat.nil? || testcat == "general" xml.actions if testcat.nil? if @opts[:masquerade] # to let tests pass xml.description "<!-- Managed by Jenkins Job Builder -->" else xml.description "<!-- Managed by cigale -->" end end xml.keepDependencies false xml.blockBuildWhenDownstreamBuilding false xml.blockBuildWhenUpstreamBuilding false xml.concurrentBuild false if val = jdef["workspace"] xml.customWorkspace val end if val = jdef["child-workspace"] and type == "matrix" xml.childCustomWorkspace val end if node = jdef["node"] xml.assignedNode node xml.canRoam false else xml.canRoam true end if retcount = jdef["retry-count"] xml.scmCheckoutRetryCount retcount end end if testcat.nil? || testcat == "properties" || testcat == "parameters" translate_properties xml, jdef end if testcat.nil? || testcat == "scm" translate_scms xml, jdef["scm"] end if testcat.nil? || testcat == "triggers" tok = jdef["token"] and xml.authToken tok translate_triggers xml, jdef["triggers"] end if testcat.nil? || testcat == "builders" if post = jdef["postbuilders"] translate_builders xml, "postbuilders", jdef["postbuilders"] end translate_builders xml, "builders", jdef["builders"] end if testcat.nil? || testcat == "publishers" translate_publishers xml, "publishers", jdef["publishers"] end if testcat.nil? || testcat == "wrappers" translate_wrappers xml, jdef["wrappers"] end end end |
#translate_matrix_project(xml, jdef) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/cigale/generator.rb', line 150 def translate_matrix_project (xml, jdef) exstrat = jdef["execution-strategy"] || {} xml.executionStrategy :class => "hudson.matrix.DefaultMatrixExecutionStrategyImpl" do xml.runSequentially boolp(exstrat["sequential"], false) if touchstone = exstrat["touchstone"] xml.touchStoneCombinationFilter touchstone["expr"] xml.touchStoneResultCondition do translate_build_status xml, touchstone["result"].upcase, false end end end if combfil = exstrat["combination-filter"] xml.combinationFilter combfil.strip else xml.combinationFilter end if axes = jdef["axes"] xml.axes do for a in axes axis = a.values.first name = axis["name"] clazz = case axis["type"] when "label-expression" "hudson.matrix.LabelExpAxis" when "slave" "hudson.matrix.LabelAxis" when "user-defined" "hudson.matrix.TextAxis" when "jdk" name ||= "jdk" "hudson.matrix.JDKAxis" when "python" name ||= "PYTHON" "jenkins.plugins.shiningpanda.matrix.PythonAxis" when "tox" name ||= "TOXENV" "jenkins.plugins.shiningpanda.matrix.ToxAxis" when "dynamic" "ca.silvermaplesolutions.jenkins.plugins.daxis.DynamicAxis" else raise "Unknown axis type: #{axis["type"]}" end xml.tag! clazz do xml.name name xml.values do for v in axis["values"] xml.string v end end case axis["type"] when "dynamic" xml.varName axis["values"].first xml.axisValues do xml.string "default" end end end end # for a in axes end else xml.axes end end |
#translate_maven_moduleset(xml, jdef) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/cigale/generator.rb', line 222 def translate_maven_moduleset (xml, jdef) mav = jdef["maven"] return unless mav if rootmod = mav["root-module"] xml.rootModule do xml.groupId rootmod["group-id"] xml.artifactId rootmod["artifact-id"] end end xml.goals mav["goals"] if mav["private-repository"] xml.localRepository :class => "hudson.maven.local_repo.PerJobLocalRepositoryLocator" end xml.ignoreUpstremChanges true # sic. xml.rootPOM mav["root-pom"] if mav["incremental-build"] xml.aggregatorStyleBuild false xml.incrementalBuild true else xml.aggregatorStyleBuild true xml.incrementalBuild false end xml.siteArchivingDisabled !boolp(mav["automatic-site-archiving"], true) xml.fingerprintingDisabled false xml.perModuleEmail true xml.archivingDisabled !boolp(mav["automatic-archiving"], true) xml.resolveDependencies !!mav["resolve-dependencies"] xml.processPlugins !!mav["process-plugins"] xml.mavenValidationLevel -1 xml.runHeadless !!mav["run-headless"] if mavcw = mav["custom-workspace"] xml.customWorkspace mavcw end if mset = mav["settings"] if mset.start_with? "org.jenkinsci" xml.settings :class => "org.jenkinsci.plugins.configfiles.maven.job.MvnSettingsProvider" do xml.settingsConfigId mset end else xml.settings :class => "jenkins.mvn.FilePathSettingsProvider" do xml.path mset end end else xml.settings :class => "jenkins.mvn.DefaultSettingsProvider" end if mgset = mav["global-settings"] if mgset.start_with? "org.jenkinsci" xml.globalSettings :class => "org.jenkinsci.plugins.configfiles.maven.job.MvnGlobalSettingsProvider" do xml.settingsConfigId mgset end else xml.globalSettings :class => "jenkins.mvn.FilePathGlobalSettingsProvider" do xml.path mgset end end else xml.globalSettings :class => "jenkins.mvn.DefaultGlobalSettingsProvider" end xml.runPostStepsIfResult do status = mav["post-step-run-condition"] || "FAILURE" translate_build_status xml, status, false end end |