module Cigale::Builder

Public Instance Methods

builder_classes() click to toggle source
# File lib/cigale/builder.rb, line 41
def builder_classes
  @builder_classes ||= {
    "critical-block-start" => CustomBuilder.new,
    "critical-block-end" => CustomBuilder.new,
    "github-notifier" => CustomBuilder.new,
    "managed-script" => CustomBuilder.new,
    "conditional-step" => CustomBuilder.new,
    "shining-panda" => CustomBuilder.new,
    "copyartifact" => CustomBuilder.new,
    "config-file-provider" => CustomBuilder.new,
    "sonatype-clm" => CustomBuilder.new,

    "inject" => "EnvInjectBuilder",
    "shell" => "hudson.tasks.Shell",
    "batch" => "hudson.tasks.BatchFile",
    "gradle" => "hudson.plugins.gradle.Gradle",
    "trigger-builds" => "hudson.plugins.parameterizedtrigger.TriggerBuilder",
    "trigger-remote" => "org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration",
    "ssh-builder" => "org.jvnet.hudson.plugins.SSHBuilder",
    "maven-target" => "hudson.tasks.Maven",
    "maven-builder" => "org.jfrog.hudson.maven3.Maven3Builder",
    "sonar" => "hudson.plugins.sonar.SonarRunnerBuilder",
    "powershell" => "hudson.plugins.powershell.PowerShell",
    "python" => "hudson.plugins.python.Python",
    "msbuild" => "hudson.plugins.msbuild.MsBuildBuilder",
    "builders-from" => "hudson.plugins.templateproject.ProxyBuilder",
    "grails" => "com.g2one.hudson.grails.GrailsBuilder",
    "system-groovy" => "hudson.plugins.groovy.SystemGroovy",
    "groovy" => "hudson.plugins.groovy.Groovy",
    "change-assembly-version" => "org.jenkinsci.plugins.changeassemblyversion.ChangeAssemblyVersion",
    "beaker" => "org.jenkinsci.plugins.beakerbuilder.BeakerBuilder",
    "multijob" => "com.tikal.jenkins.plugins.multijob.MultiJobBuilder",
    "cmake" => "hudson.plugins.cmake.CmakeBuilder",
    "ant" => "hudson.tasks.Ant",
    "sbt" => "org.jvnet.hudson.plugins.SbtPluginBuilder",
    "dsl" => "javaposse.jobdsl.plugin.ExecuteDslScripts",
    "artifact-resolver" => "org.jvnet.hudson.plugins.repositoryconnector.ArtifactResolver",
  }
end
condition_basedirs() click to toggle source
# File lib/cigale/builder/conditional.rb, line 165
def condition_basedirs
  @condition_basedirs ||= {
    "jenkins-home" => "org.jenkins_ci.plugins.run_condition.common.BaseDirectory$JenkinsHome",
    "workspace" => "org.jenkins_ci.plugins.run_condition.common.BaseDirectory$Workspace",
  }
end
condition_classes() click to toggle source
# File lib/cigale/builder/conditional.rb, line 172
def condition_classes
  @condition_classes ||= {
    "regex-match" => "org.jenkins_ci.plugins.run_condition.core.ExpressionCondition",
    "files-match" => "org.jenkins_ci.plugins.run_condition.core.FilesMatchCondition",
    "file-exists" => "org.jenkins_ci.plugins.run_condition.core.FileExistsCondition",
    "num-comp" => "org.jenkins_ci.plugins.run_condition.core.NumericalComparisonCondition",
    "execution-node" => "org.jenkins_ci.plugins.run_condition.core.NodeCondition",
    "current-status" => "org.jenkins_ci.plugins.run_condition.core.StatusCondition",
    "build-cause" => "org.jenkins_ci.plugins.run_condition.core.CauseCondition",
    "strings-match" => "org.jenkins_ci.plugins.run_condition.core.StringsMatchCondition",
    "time" => "org.jenkins_ci.plugins.run_condition.core.TimeCondition",
    "day-of-week" => "org.jenkins_ci.plugins.run_condition.core.DayCondition",
    "not" => "org.jenkins_ci.plugins.run_condition.logic.Not",
    "and" => "org.jenkins_ci.plugins.run_condition.logic.And",
    "or" => "org.jenkins_ci.plugins.run_condition.logic.Or",
    "shell" => "org.jenkins_ci.plugins.run_condition.contributed.ShellCondition",
    "always" => "org.jenkins_ci.plugins.run_condition.core.AlwaysRun",
    "never" => "org.jenkins_ci.plugins.run_condition.core.NeverRun",
  }
end
condition_comparator_classes() click to toggle source
# File lib/cigale/builder/conditional.rb, line 155
def condition_comparator_classes
  @condition_comparator_classes ||= {
    "equal" => "org.jenkins_ci.plugins.run_condition.core.NumericalComparisonCondition$EqualTo",
  }
end
translate_ant_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/ant.rb, line 4
def translate_ant_builder (xml, bdef)
  case bdef
  when String
    bdef = {"targets" => bdef}
  end

  if buildfile = bdef["buildfile"]
    xml.buildFile buildfile
  end
  if javaopts = bdef["java-opts"]
    xml.antOpts javaopts.join(" ")
  end
  if properties = bdef["properties"]
    content = properties.each_pair.map do |pair|
      "#{pair[0]}=#{pair[1]}\n"
    end.join ""
    xml.properties content
  end
  xml.targets bdef["targets"]
  xml.antName bdef["ant-name"] ||  "default"
end
translate_artifact_resolver_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/artifact-resolver.rb, line 4
def translate_artifact_resolver_builder (xml, bdef)
  xml.targetDirectory bdef["target-directory"]
  xml.artifacts do
    for artifact in bdef["artifacts"]
      xml.tag! "org.jvnet.hudson.plugins.repositoryconnector.Artifact" do
        xml.groupId artifact["group-id"]
        xml.artifactId artifact["group-id"]
        xml.classifier artifact["classifier"]
        xml.version artifact["version"]
        xml.extension artifact["extension"] || "jar"
        xml.targetFileName artifact["target-file-name"]
      end
    end
  end
  xml.failOnError bdef["fail-on-error"]
  xml.enableRepoLogging bdef["repository-logging"]
  xml.snapshotUpdatePolicy "never"
  xml.releaseUpdatePolicy "never"
  xml.snapshotChecksumPolicy "warn"
  xml.releaseChecksumPolicy "warn"
end
translate_batch_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/batch.rb, line 3
def translate_batch_builder (xml, bdef)
  xml.command bdef
end
translate_beaker_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/beaker.rb, line 4
def translate_beaker_builder (xml, bdef)
  if path = bdef["path"]
    xml.jobSource :class => "org.jenkinsci.plugins.beakerbuilder.FileJobSource" do
      xml.jobPath path
    end
  elsif content = bdef["content"]
    xml.jobSource :class => "org.jenkinsci.plugins.beakerbuilder.StringJobSource" do
      xml.jobContent content
    end
  end
  xml.downloadFiles !!bdef["download-logs"]
end
translate_build_status(xml, status, write_complete_build=true) click to toggle source
# File lib/cigale/builder/build_status.rb, line 4
def translate_build_status (xml, status, write_complete_build=true)
  @build_statuses ||= {
    "SUCCESS" => {
      "ordinal" => 0,
      "color" => "BLUE",
      "completeBuild" => true,
    },
    "UNSTABLE" => {
      "ordinal" => 1,
      "color" => "YELLOW",
      "completeBuild" => true,
    },
    "FAILURE" => {
      "ordinal" => 2,
      "color" => "RED",
      "completeBuild" => true,
    },
    "NOT_BUILD" => {
      "ordinal" => 3,
      "color" => "NOTBUILD",
      "completeBuild" => false,
    },
    "ABORTED" => {
      "ordinal" => 4,
      "color" => "ABORTED",
      "completeBuild" => false,
    },
  }

  spec = @build_statuses[status] or raise "Unknown build status: '#{status}'"
  xml.name status
  for k, v in spec
    next if (k == "completeBuild" && !write_complete_build)
    xml.tag! k, v
  end
end
translate_builders(xml, tag, builders) click to toggle source
# File lib/cigale/builder.rb, line 81
def translate_builders (xml, tag, builders)
  builders = toa builders
  if builders.empty?
    return xml.tag! tag
  end

  xml.tag! tag do
    for b in builders
      type, spec = asplode b
      translate("builder", xml, type, spec)
    end
  end
end
translate_builders_from_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/builders-from.rb, line 3
def translate_builders_from_builder (xml, bdef)
  xml.projectName bdef
end
translate_change_assembly_version_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/change-assembly-version.rb, line 3
def translate_change_assembly_version_builder (xml, bdef)
  xml.task bdef["version"]
  xml.assemblyFile bdef["assembly-file"] || "AssemblyInfo.cs"
end
translate_cmake_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/cmake.rb, line 4
def translate_cmake_builder (xml, bdef)
  xml.sourceDir bdef["source-dir"]
  xml.buildDir bdef["build-dir"]
  xml.installDir bdef["install-dir"]

  xml.buildType "Debug"
  btype = bdef["build-type"]
  if btype == "Debug"
    xml.otherBuildType
  else
    xml.otherBuildType btype
  end

  xml.generator bdef["generator"] || "Unix Makefiles"
  xml.makeCommand bdef["make-command"] || "make"
  xml.installCommand bdef["install-command"] || "make install"
  xml.preloadScript bdef["preload-script"]
  xml.cmakeArgs bdef["other-arguments"]
  xml.projectCmakePath bdef["custom-cmake-path"]
  xml.cleanBuild bdef["clean-build-dir"]
  xml.cleanInstallDir bdef["clean-install-dir"]
  xml.builderImpl
end
translate_condition(tag, xml, bdef) click to toggle source
# File lib/cigale/builder/conditional.rb, line 53
def translate_condition (tag, xml, bdef)
  ckind = bdef["condition-kind"] || raise("Missing condition-kind: #{bdef.inspect}")
  cclass = condition_classes[ckind]
  raise "Unknown condition kind: #{ckind}" unless cclass

  if %w(always never).include? ckind
    xml.tag! tag, :class => cclass
  else
    xml.tag! tag, :class => cclass do
      case ckind
      when "regex-match"
        xml.expression bdef["regex"] || raise("Missing regex: #{bdef.inspect}")
        xml.label bdef["label"] || raise("Missing label: #{bdef.inspect}")
      when "files-match"
        xml.includes bdef["include-pattern"].join(",")
        xml.excludes bdef["exclude-pattern"].join(",")

        bdir = bdef["condition-basedir"]
        bdirclass = condition_basedirs[bdir] or raise "Unknown base dir for files-match: '#{bdir}'"
        xml.baseDir :class => bdirclass
      when "file-exists"
        xml.file bdef["condition-filename"]
        bdir = bdef["condition-basedir"]
        bdirclass = condition_basedirs[bdir] or raise "Unknown base dir for file-exists: '#{bdir}'"
        xml.baseDir :class => bdirclass
      when "execution-node"
        xml.allowedNodes do
          for node in bdef["nodes"]
            xml.string node
          end
        end
      when "current-status"
        worst = bdef["condition-worst"] and xml.worstResult do
          translate_build_status xml, worst
        end
        best = bdef["condition-best"] and xml.bestResult do
          translate_build_status xml, best
        end
      when "num-comp"
        xml.lhs bdef["lhs"]
        xml.rhs bdef["rhs"]

        comp = bdef["comparator"]
        cclass = condition_comparator_classes[comp] or raise "Unknown num-comp comparator: #{comp}"
        xml.comparator :class => cclass
      when "build-cause"
        xml.buildCause bdef["cause"]
        xml.exclusiveCause bdef["exclusive-cause"]
      when "strings-match"
        xml.arg1 bdef["condition-string1"]
        xml.arg2 bdef["condition-string2"]
        xml.ignoreCase bdef["condition-case-insensitive"]
      when "time"
        xml.earliestHours bdef["earliest-hour"]
        xml.earliestMinutes bdef["earliest-min"]
        xml.latestHours bdef["latest-hour"]
        xml.latestMinutes bdef["latest-min"]
        xml.useBuildTime bdef["use-build-time"] || false
      when "day-of-week"
        @day_of_week_classes ||= {
          "weekday" => "org.jenkins_ci.plugins.run_condition.core.DayCondition$Weekday",
          "select-days" => "org.jenkins_ci.plugins.run_condition.core.DayCondition$SelectDays",
        }

        dsel = bdef["day-selector"]
        dclass = @day_of_week_classes[dsel] or raise "Unknown day-of-week selector: #{dsel}"

        case dsel
        when "select-days"
          xml.daySelector :class => dclass do
            xml.days do
              %w(SUN MON TUE WED THU FRI SAT).each_with_index do |item, index|
                xml.tag! "org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day" do
                  xml.day index + 1
                  xml.selected (true == bdef["days"][item]) || false
                end
              end
            end
          end
        else
          xml.daySelector :class => dclass
        end

        xml.useBuildTime bdef["use-build-time"]
      when "not"
        translate_condition "condition", xml, bdef["condition-operand"]
      when "or", "and"
        operands = bdef["condition-operands"]
        xml.conditions do
          for operand in operands
            xml.tag! "org.jenkins__ci.plugins.run__condition.logic.ConditionContainer" do
              translate_condition "condition", xml, operand
            end
          end
        end
      when "shell"
        xml.command bdef["condition-command"]
      end
    end # xml.tag!
  end # always/never or not
end
translate_condition_runner(xml, bdef) click to toggle source
# File lib/cigale/builder/conditional.rb, line 161
def translate_condition_runner (xml, bdef)
  xml.runner :class => "org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"
end
translate_conditional_multi_step_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/conditional.rb, line 35
def translate_conditional_multi_step_builder (xml, bdef)
  xml.conditionalbuilders do
    for step in bdef["steps"]
      stype, sdef = first_pair(step)
      clazz = builder_classes[stype]
      raise "Unknown builder type: #{stype}" unless clazz

      xml.tag! clazz do
        self.send "translate_#{underize(stype)}_builder", xml, sdef
      end
    end
  end

  translate_condition "runCondition", xml, bdef

  translate_condition_runner xml, bdef
end
translate_conditional_single_step_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/conditional.rb, line 21
def translate_conditional_single_step_builder (xml, bdef)
  translate_condition "condition", xml, bdef

  translate_condition_runner xml, bdef

  stype, sdef = first_pair(bdef["steps"].first)
  clazz = builder_classes[stype]
  raise "Unknown builder type: #{stype}" unless clazz

  xml.tag! "buildStep", :class => clazz do
    self.send "translate_#{underize(stype)}_builder", xml, sdef
  end
end
translate_conditional_step_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/conditional.rb, line 6
def translate_conditional_step_builder (xml, bdef)
  case toa(bdef["steps"]).size
  when 0
    raise "Need 1 or more steps for conditional: #{bdef.inspect}"
  when 1
    xml.tag! "org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder" do
      translate_conditional_single_step_builder xml, bdef
    end
  else
    xml.tag! "org.jenkinsci.plugins.conditionalbuildstep.ConditionalBuilder" do
      translate_conditional_multi_step_builder xml, bdef
    end
  end
end
translate_config_file_provider_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/config-file-provider.rb, line 4
def translate_config_file_provider_builder (xml, bdef)
  xml.tag! "org.jenkinsci.plugins.configfiles.builder.ConfigFileBuildStep", :plugin => "config-file-provider" do
    xml.managedFiles do
      for file in toa bdef["files"]
        xml.tag! "org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile" do
          xml.fileId file["file-id"]
          xml.targetLocation file["target"]
          xml.variable file["variable"]
        end
      end
    end
  end
end
translate_copyartifact_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/copyartifact.rb, line 4
def translate_copyartifact_builder (xml, bdef)
  bclass = case
  when bdef["projects"]
    "hudson.plugins.copyartifact.CopyArtifactPermissionProperty"
  else
    "hudson.plugins.copyartifact.CopyArtifact"
  end

  xml.tag! bclass do
    if projects = bdef["projects"]
      xml.projectNameList do
        for project in bdef["projects"]
          xml.string project
        end
      end
    else
      xml.project bdef["project"]
    end

    val = bdef["filter"] and xml.filter val
    val = bdef["target"] and xml.target val
    val = bdef["flatten"] and xml.flatten val
    val = bdef["optional"] and xml.optional val
    val = bdef["parameter-filters"] and xml.parameters val

    begin
      whichbuild = bdef["which-build"]
      @which_build_options ||= {
        "last-completed" => "hudson.plugins.copyartifact.LastCompletedBuildSelector",
        "specific-build" => "hudson.plugins.copyartifact.SpecificBuildSelector",
      }

      wclass = @which_build_options[whichbuild] or raise "Unknown build selector in copyartifact: #{whichbuild}"
      case whichbuild
      when "specific-build"
        xml.selector :class => wclass do
          xml.buildNumber bdef["build-number"]
        end
      else
        xml.selector :class => wclass
      end
    end
  end
end
translate_critical_block_end_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/exclusion.rb, line 7
def translate_critical_block_end_builder (xml, bdef)
  xml.tag! "org.jvnet.hudson.plugins.exclusion.CriticalBlockEnd", :plugin => "Exclusion"
end
translate_critical_block_start_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/exclusion.rb, line 3
def translate_critical_block_start_builder (xml, bdef)
  xml.tag! "org.jvnet.hudson.plugins.exclusion.CriticalBlockStart", :plugin => "Exclusion"
end
translate_dsl_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/dsl.rb, line 4
def translate_dsl_builder (xml, bdef)
  if script = bdef["script-text"]
    xml.scriptText script
    xml.usingScriptText true
  elsif target = bdef["target"]
    xml.targets target
    xml.usingScriptText false
  end
  xml.ignoreExisting bdef["ignore-existing"]
  xml.removedJobAction bdef["removed-job-action"]
  xml.removedViewAction bdef["removed-view-action"]
  xml.lookupStrategy bdef["lookup-strategy"]
  xml.additionalClasspath bdef["additional-classpath"]
end
translate_github_notifier_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/github-notifier.rb, line 3
def translate_github_notifier_builder (xml, bdef)
  xml.tag! "com.cloudbees.jenkins.GitHubSetCommitStatusBuilder"
end
translate_gradle_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/gradle.rb, line 3
def translate_gradle_builder (xml, bdef)
  xml.description
  xml.tasks bdef["tasks"]
  xml.buildFile
  xml.rootBuildScriptDir bdef["root-build-script-dir"]
  xml.gradleName bdef["gradle-name"]
  xml.useWrapper bdef["wrapper"]
  xml.makeExecutable bdef["executable"]
  xml.switches bdef["switches"].join("\n")
  xml.fromRootBuildScriptDir (not bdef["root-build-script-dir"].nil?)
end
translate_grails_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/grails.rb, line 3
def translate_grails_builder (xml, bdef)
  xml.targets bdef["targets"]
  xml.name bdef["name"]
  xml.grailsWorkDir bdef["work-dir"]
  xml.projectWorkDir bdef["project-dir"]
  xml.projectBaseDir bdef["base-dir"]
  xml.serverPort bdef["server-port"]
  xml.properties bdef["properties"]
  xml.forceUpgrade bdef["force-upgrade"]
  xml.nonInteractive bdef["non-interactive"]
  xml.useWrapper bdef["use-wrapper"]
  xml.plainOutput bdef["plain-output"]
  xml.stackTrace bdef["stack-trace"]
  xml.verbose bdef["verbose"]
  xml.refreshDependencies bdef["refresh-dependencies"]
end
translate_groovy_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/groovy.rb, line 4
def translate_groovy_builder (xml, bdef)
  if cmd = bdef["command"]
    xml.scriptSource :class => "hudson.plugins.groovy.StringScriptSource" do
      xml.command cmd
    end
  elsif file = bdef["file"]
    xml.scriptSource :class => "hudson.plugins.groovy.FileScriptSource" do
      xml.scriptFile file
    end
  end
  xml.groovyName bdef["version"] || "(Default)"
  xml.parameters bdef["parameters"]
  xml.scriptParameters bdef["script-parameters"]
  xml.properties bdef["properties"]
  xml.javaOpts bdef["java-opts"]
  xml.classPath
end
translate_inject_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/inject.rb, line 4
def translate_inject_builder (xml, bdef)
  xml.info do
    val = bdef["properties-file"] and xml.propertiesFilePath val
    val = bdef["properties-content"] and xml.propertiesContent val
    val = bdef["script-file"] and xml.scriptFilePath val
    val = bdef["script-content"] and xml.scriptContent val
  end
end
translate_managed_script_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/managed-script.rb, line 3
def translate_managed_script_builder (xml, bdef)
  sclass = case bdef["type"]
  when "script"
    "org.jenkinsci.plugins.managedscripts.ScriptBuildStep"
  when "batch"
    "org.jenkinsci.plugins.managedscripts.WinBatchBuildStep"
  else
    raise "Unknown managed script type: #{bdef["type"]}"
  end

  xml.tag! sclass do
    case bdef["type"]
    when "script"
      xml.buildStepId bdef["script-id"]
    when "batch"
      xml.command bdef["script-id"]
    end
    xml.buildStepArgs do
      for arg in bdef["args"]
        xml.string arg
      end
    end
  end
end
translate_maven_builder_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/maven-builder.rb, line 3
def translate_maven_builder_builder (xml, bdef)
  xml.mavenName bdef["name"]
  xml.goals bdef["goals"]
  xml.rootPom bdef["pom"]
  xml.mavenOpts
end
translate_maven_target_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/maven-target.rb, line 3
def translate_maven_target_builder (xml, bdef)
  xml.targets bdef["goals"]
  if props = bdef["properties"]
    xml.properties props.join("\n")
  else
    xml.properties
  end
  xml.mavenName bdef["maven-version"]
  if pom = bdef["pom"]
    xml.pom pom
  end

  privrepo = bdef["private-repository"]
  xml.usePrivateRepository !!privrepo

  if javaopts = bdef["java-opts"]
    xml.jvmOptions javaopts.join(" ")
  end

  if settings = bdef["settings"]
    if settings.start_with? "org.jenkinsci.plugins.configfiles.maven"
      xml.settings :class => "org.jenkinsci.plugins.configfiles.maven.job.MvnSettingsProvider" do
        xml.settingsConfigId settings
      end
    else
      xml.settings :class => "jenkins.mvn.FilePathSettingsProvider" do
        xml.path settings
      end
    end
  else
    xml.settings :class => "jenkins.mvn.DefaultSettingsProvider"
  end

  if gsettings = bdef["global-settings"]
    if gsettings.start_with? "org.jenkinsci.plugins.configfiles.maven"
      xml.globalSettings :class => "org.jenkinsci.plugins.configfiles.maven.job.MvnGlobalSettingsProvider" do
        xml.settingsConfigId gsettings
      end
    else
      xml.globalSettings :class => "jenkins.mvn.FilePathGlobalSettingsProvider" do
        xml.path gsettings
      end
    end
  else
    xml.globalSettings :class => "jenkins.mvn.DefaultGlobalSettingsProvider"
  end
end
translate_msbuild_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/msbuild.rb, line 3
def translate_msbuild_builder (xml, bdef)
  xml.msBuildName bdef["msbuild-version"]
  xml.msBuildFile bdef["solution-file"]
  xml.cmdLineArgs bdef["extra-parameters"]
  xml.buildVariablesAsProperties bdef["pass-build-variables"]
  xml.continueOnBuildFailure bdef["continue-on-build-failure"]
end
translate_multijob_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/multijob.rb, line 4
def translate_multijob_builder (xml, bdef)
  xml.phaseName bdef["name"]
  xml.continuationCondition bdef["condition"]
  xml.phaseJobs do
    for project in bdef["projects"]
      xml.tag! "com.tikal.jenkins.plugins.multijob.PhaseJobsConfig" do
        xml.jobName project["name"]
        xml.currParams project["current-parameters"]

        nodelabel = project["node-label"]
        has_gitrev = project.has_key?("git-revision")
        propfile = project["property-file"]
        preparams = project["predefined-parameters"]

        if nodelabel || has_gitrev || propfile || preparams
          xml.configs do
            if nodelabel
              xml.tag! "org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter" do
                xml.name project["node-label-name"]
                xml.nodeLabel nodelabel
              end
            end

            if has_gitrev
              gitrev = project["git-revision"]
              xml.tag! "hudson.plugins.git.GitRevisionBuildParameters" do
                xml.combineQueuedCommits !gitrev
              end
            end

            if propfile
              xml.tag! "hudson.plugins.parameterizedtrigger.FileBuildParameters" do
                xml.propertiesFile propfile
                xml.failTriggerOnMissing true
              end
            end

            if preparams
              xml.tag! "hudson.plugins.parameterizedtrigger.PredefinedBuildParameters" do
                xml.properties preparams
              end
            end
          end # configs
        else
          xml.configs
        end

        if encond = project["enable-condition"]
          xml.enableCondition true
          xml.condition encond
        end

        if killphase = project["kill-phase-on"]
          xml.killPhaseOnJobResultCondition killphase
        end

      end
    end
  end
end
translate_powershell_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/powershell.rb, line 3
def translate_powershell_builder (xml, bdef)
  xml.command bdef
end
translate_python_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/python.rb, line 3
def translate_python_builder (xml, bdef)
  xml.command bdef
end
translate_sbt_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/sbt.rb, line 4
def translate_sbt_builder (xml, bdef)
  xml.name bdef["name"]
  xml.jvmFlags bdef["jvm-flags"]
  xml.sbtFlags "-Dsbt.log.noformat=true"
  xml.actions bdef["actions"]
  xml.subdirPath
end
translate_shell_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/shell.rb, line 3
def translate_shell_builder (xml, bdef)
  xml.command bdef
end
translate_shining_panda_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/shining-panda.rb, line 3
def translate_shining_panda_builder (xml, bdef)
  env = bdef["build-environment"]
  bclass = case env
  when "python"
    "jenkins.plugins.shiningpanda.builders.PythonBuilder"
  when "custom"
    "jenkins.plugins.shiningpanda.builders.CustomPythonBuilder"
  when "virtualenv"
    "jenkins.plugins.shiningpanda.builders.VirtualenvBuilder"
  else
    raise "Unknown build environment for shining-panda: #{env}"
  end

  xml.tag! bclass do
    ver = bdef["python-version"] and xml.pythonName ver

    case env
    when "virtualenv"
      xml.home bdef["name"]
      xml.clear bdef["clear"]
      xml.useDistribute bdef["use-distribute"]
      xml.systemSitePackages bdef["system-site-packages"]
    when "custom"
      xml.home bdef["home"]
    end

    xml.nature bdef["nature"]
    xml.command bdef["command"]
    xml.ignoreExitCode bdef["ignore-exit-code"]
  end
end
translate_sonar_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/sonar.rb, line 3
def translate_sonar_builder (xml, bdef)
  xml.installationName bdef["sonar-name"]
  xml.task bdef["task"]
  xml.project bdef["project"]
  xml.properties bdef["properties"]
  xml.javaOpts bdef["java-opts"]
end
translate_sonatype_clm_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/sonatype-clm.rb, line 3
def translate_sonatype_clm_builder (xml, bdef)
  xml.tag! "com.sonatype.insight.ci.hudson.PreBuildScan", :plugin => "sonatype-clm-ci" do
    xml.billOfMaterialsToken bdef["application-name"]
    xml.failOnClmServerFailures bdef["fail-on-clm-server-failure"]
    xml.stageId bdef["stage"]
    xml.pathConfig do
      xml.scanTargets bdef["scan-targets"]
      xml.moduleExcludes bdef["module-excludes"]
      xml.scanProperties bdef["advanced-options"]
    end
  end
end
translate_ssh_builder_builder(xml, bdef) click to toggle source

sigh…

# File lib/cigale/builder/ssh.rb, line 4
def translate_ssh_builder_builder (xml, bdef)
  xml.siteName bdef["ssh-user-ip"]
  xml.command bdef["command"]
end
translate_system_groovy_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/system-groovy.rb, line 3
def translate_system_groovy_builder (xml, bdef)
  if cmd = bdef["command"]
    xml.scriptSource :class => "hudson.plugins.groovy.StringScriptSource" do
      xml.command cmd
    end
  elsif file = bdef["file"]
    xml.scriptSource :class => "hudson.plugins.groovy.FileScriptSource" do
      xml.scriptFile file
    end
  end
  xml.bindings bdef["bindings"]
  xml.classpath bdef["class-path"]
end
translate_trigger_builds_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/trigger-builds.rb, line 4
def translate_trigger_builds_builder (xml, bdef)
  xml.configs do
    for build in bdef
      xml.tag! "hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig" do
        propfile = build["property-file"]
        predefparams = build["predefined-parameters"]
        boolparams = build["bool-parameters"]
        same_node = build["same-node"]
        currpar = build["current-parameters"]
        gitrev = build["git-revision"]
        svnrev = build["svn-revision"]
        nodelabel = build["node-label"]

        if propfile || boolparams || predefparams || same_node || currpar || gitrev || svnrev || nodelabel
          xml.configs do
            propfile and xml.tag! "hudson.plugins.parameterizedtrigger.FileBuildParameters" do
              xml.propertiesFile propfile
              tom = if build.has_key?("property-file-fail-on-missing")
                build["property-file-fail-on-missing"]
              else
                true
              end
              xml.failTriggerOnMissing tom
            end

            same_node and xml.tag! "hudson.plugins.parameterizedtrigger.NodeParameters"

            currpar and xml.tag! "hudson.plugins.parameterizedtrigger.CurrentBuildParameters"
            gitrev and xml.tag! "hudson.plugins.git.GitRevisionBuildParameters" do
              xml.combineQueuedCommits false
            end
            svnrev and xml.tag! "hudson.plugins.parameterizedtrigger.SubversionRevisionBuildParameters"

            predefparams and xml.tag! "hudson.plugins.parameterizedtrigger.PredefinedBuildParameters" do
              xml.properties predefparams
            end

            nodelabel and xml.tag! "org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.NodeLabelBuildParameter" do
              xml.name build["node-label-name"]
              xml.nodeLabel nodelabel
            end

            boolparams and xml.tag! "hudson.plugins.parameterizedtrigger.BooleanParameters" do
              xml.configs do
                for bp in boolparams
                  xml.tag! "hudson.plugins.parameterizedtrigger.BooleanParameterConfig" do
                    xml.name bp["name"]
                    xml.value !!bp["value"]
                  end
                end
              end
            end
          end
        else
          xml.configs :class => "java.util.Collections$EmptyList"
        end

        if factories = build["parameter-factories"]
          xml.configFactories do
            for f in factories
              fname = f["factory"]
              fclass = trigger_factories[fname] or raise "Unknown trigger param factory type: #{fname}"
              xml.tag! fclass do
                case fname
                when "allnodesforlabel"
                  xml.name f["name"]
                  xml.nodeLabel f["node-label"]
                  ign = if f.has_key?("ignore-offline-nodes")
                    f["ignore-offline-nodes"]
                  else true
                    true
                  end
                  xml.ignoreOfflineNodes ign
                when "filebuild"
                  xml.filePattern f["file-pattern"]
                  xml.noFilesFoundAction f["no-files-found-action"] || "SKIP"
                when "binaryfile"
                  xml.parameterName f["parameter-name"]
                  xml.filePattern f["file-pattern"]
                  xml.noFilesFoundAction f["no-files-found-action"] || "SKIP"
                when "counterbuild"
                  xml.from f["from"]
                  xml.to f["to"]
                  xml.step f["step"]
                  xml.paramExpr f["parameters"]
                  xml.validationFail f["validation-fail"] || "FAIL"
                end
              end
            end
          end
        end

        projects = build["project"]
        if Array === projects
          xml.projects projects.join(",")
        else
          xml.projects projects || "build_started"
        end
        xml.condition "ALWAYS"
        xml.triggerWithNoParameters false
        xml.buildAllNodesWithLabel false

        if build["block"]
          thresholds = build["block-thresholds"] || {}

          xml.block do
            threshold = thresholds["build-step-failure-threshold"]
            if threshold != "never"
              xml.buildStepFailureThreshold do
                threshold = "FAILURE" if (threshold === true || threshold.nil?)
                translate_build_status(xml, threshold)
              end
            end

            threshold = thresholds["unstable-threshold"]
            if threshold != "never"
              xml.unstableThreshold do
                threshold = "UNSTABLE" if (threshold === true || threshold.nil?)
                translate_build_status(xml, threshold)
              end
            end

            threshold = thresholds["failure-threshold"]
            if threshold != "never"
              xml.failureThreshold do
                threshold = "FAILURE" if (threshold === true || threshold.nil?)
                translate_build_status(xml, threshold)
              end
            end
          end # block
        end
      end # BlockableBuildTriggerConfig
    end # for b in builds
  end # configs

end
translate_trigger_remote_builder(xml, bdef) click to toggle source
# File lib/cigale/builder/trigger-remote.rb, line 4
def translate_trigger_remote_builder (xml, bdef)
  xml.remoteJenkinsName bdef["remote-jenkins-name"]
  xml.token bdef["token"]
  xml.job bdef["job"]
  dontFailBuild = if bdef.has_key?("should-fail-build")
    !bdef["should-fail-build"]
  else
    false
  end
  xml.shouldNotFailBuild dontFailBuild
  xml.pollInterval bdef["poll-interval"] || 10
  xml.connectionRetryLimit bdef["connection-retry-limit"] || 5
  xml.preventRemoteBuildQueue bdef["prevent-remote-build-queue"] || false
  xml.blockBuildUntilComplete bdef["block"] || true

  if preparams = bdef["predefined-parameters"]
    xml.parameters preparams
    xml.parameterList do
      for param in preparams.strip.split("\n")
        xml.string param
      end
    end
  end

  if propfile = bdef["property-file"]
    xml.loadParamsFromFile true
    xml.parameterFile propfile
  else
    xml.loadParamsFromFile false
  end
  xml.overrideAuth false
end
trigger_factories() click to toggle source
# File lib/cigale/builder/trigger-builds.rb, line 141
def trigger_factories
  @trigger_factories ||= {
    "allnodesforlabel" => "org.jvnet.jenkins.plugins.nodelabelparameter.parameterizedtrigger.AllNodesForLabelBuildParameterFactory",
    "filebuild" => "hudson.plugins.parameterizedtrigger.FileBuildParameterFactory",
    "binaryfile" => "hudson.plugins.parameterizedtrigger.BinaryFileParameterFactory",
    "counterbuild" => "hudson.plugins.parameterizedtrigger.CounterBuildParameterFactory",
  }
end