module Cigale::Property

Public Instance Methods

property_classes() click to toggle source
# File lib/cigale/property.rb, line 21
def property_classes
  @property_classes ||= {
    "inject" => "EnvInjectJobProperty",
    "least-load" => "org.bstick12.jenkinsci.plugins.leastload.LeastLoadDisabledProperty",
    "delivery-pipeline" => "se.diabol.jenkins.pipeline.PipelineProperty",
    "ownership" => "com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty",
    "builds-chain-fingerprinter" => "org.jenkinsci.plugins.buildschainfingerprinter.AutomaticFingerprintJobProperty",
    "slave-utilization" => "com.suryagaddipati.jenkins.SlaveUtilizationProperty",
    "authorization" => "hudson.security.AuthorizationMatrixProperty",
    "batch-tasks" => "hudson.plugins.batch__task.BatchTaskProperty",
    "heavy-job" => "hudson.plugins.heavy__job.HeavyJobProperty",
    "throttle" => "hudson.plugins.throttleconcurrents.ThrottleJobProperty",
    "zeromq-event" => "org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty",
    "slack" => ["jenkins.plugins.slack.SlackNotifier_-SlackJobProperty", :plugin => "slack@1.8.1"],
    "copyartifact" => CustomProperty.new,
  }
end
translate_authorization_property(xml, pdef) click to toggle source
# File lib/cigale/property/authorization.rb, line 3
def translate_authorization_property (xml, pdef)
  @authorization_classes ||= {
    "job-read" => "hudson.model.Item.Read",
    "job-extended-read" => "hudson.model.Item.ExtendedRead",
  }

  pdef.each do |role, perms|
    for perm in perms
      pclass = @authorization_classes[perm] or raise "Unknown authorization permission: #{perm}"
      xml.permission "#{pclass}:#{role}"
    end
  end
end
translate_batch_tasks_property(xml, pdef) click to toggle source
# File lib/cigale/property/batch-tasks.rb, line 3
def translate_batch_tasks_property (xml, pdef)
  xml.tasks do
    for task in pdef
      xml.tag! "hudson.plugins.batch__task.BatchTask" do
        xml.name task["name"]
        xml.script task["script"]
      end
    end
  end
end
translate_builds_chain_fingerprinter_property(xml, pdef) click to toggle source
# File lib/cigale/property/builds-chain-fingerprinter.rb, line 3
def translate_builds_chain_fingerprinter_property (xml, pdef)
  xml.isPerBuildsChainEnabled pdef["per-builds-chain"]
  xml.isPerJobsChainEnabled pdef["per-job-chain"]
end
translate_copyartifact_property(xml, pdef) click to toggle source
# File lib/cigale/property/copyartifact.rb, line 3
def translate_copyartifact_property (xml, pdef)
  xml.tag! "hudson.plugins.copyartifact.CopyArtifactPermissionProperty", :plugin => "copyartifact" do
    xml.projectNameList do
      xml.string pdef["projects"]
    end
  end
end
translate_delivery_pipeline_property(xml, pdef) click to toggle source
# File lib/cigale/property/delivery-pipeline.rb, line 3
def translate_delivery_pipeline_property (xml, pdef)
  xml.stageName pdef["stage"]
  xml.taskName pdef["task"]
end
translate_heavy_job_property(xml, pdef) click to toggle source
# File lib/cigale/property/heavy-job.rb, line 3
def translate_heavy_job_property (xml, pdef)
  xml.weight pdef["weight"]
end
translate_inject_property(xml, pdef) click to toggle source
# File lib/cigale/property/inject.rb, line 3
def translate_inject_property (xml, pdef)
  xml.info do
    if props = pdef["properties-content"]
      xml.propertiesContent props
    end
    xml.loadFilesFromMaster false
  end
  xml.on true
  xml.keepJenkinsSystemVariables boolp(pdef["keep-system-variables"], true)
  xml.keepBuildVariables boolp(pdef["keep-build-variables"], true)
  xml.overrideBuildParameters boolp(pdef["override-build-parameters"], false)
end
translate_least_load_property(xml, pdef) click to toggle source
# File lib/cigale/property/least-load.rb, line 3
def translate_least_load_property (xml, pdef)
  xml.leastLoadDisabled pdef["disabled"]
end
translate_ownership_property(xml, pdef) click to toggle source
# File lib/cigale/property/ownership.rb, line 3
def translate_ownership_property (xml, pdef)
  xml.ownership do
    xml.ownershipEnabled true
    xml.primaryOwnerId pdef["owner"]
    xml.coownersIds do
      for co in pdef["co-owners"]
        xml.string co
      end
    end
  end
end
translate_properties(xml, jdef) click to toggle source
# File lib/cigale/property.rb, line 39
def translate_properties (xml, jdef)
  props = toa jdef["properties"]
  parameters = toa jdef["parameters"]

  if props.empty? && parameters.empty?
    return xml.properties
  end

  xml.properties do
    translate_properties_inner xml, props

    unless parameters.empty?
      xml.tag! "hudson.model.ParametersDefinitionProperty" do
        xml.parameterDefinitions do
          translate_parameters_inner xml, parameters
        end
      end
    end
  end
end
translate_properties_inner(xml, props) click to toggle source
# File lib/cigale/property.rb, line 60
def translate_properties_inner (xml, props)
  sidebars = []

  for p in props
    type, spec = asplode(p)
    case type
    when "sidebar"
      sidebars << spec
    else
      translate("property", xml, type, spec)
    end
  end # for

  unless sidebars.empty?
    translate_sidebar_properties xml, sidebars
  end
end
translate_sidebar_properties(xml, pdefs) click to toggle source
# File lib/cigale/property/sidebar.rb, line 3
def translate_sidebar_properties (xml, pdefs)
  xml.tag! "hudson.plugins.sidebar__link.ProjectLinks" do
    xml.links do
      for pdef in pdefs
        xml.tag! "hudson.plugins.sidebar__link.LinkAction" do
          xml.url pdef["url"]
          xml.text pdef["text"]
          xml.icon pdef["icon"]
        end
      end
    end
  end
end
translate_slack_property(xml, pdef) click to toggle source
# File lib/cigale/property/slack.rb, line 3
def translate_slack_property (xml, pdef)
  xml.teamDomain pdef["team-domain"]
  xml.token pdef["token"]
  xml.room pdef["room"]

  notify = toh pdef["notify"]

  xml.startNotification boolp(notify["start"], false)
  xml.notifySuccess boolp(notify["success"], false)
  xml.notifyAborted boolp(notify["aborted"], false)
  xml.notifyNotBuilt boolp(notify["not-built"], false)
  xml.notifyUnstable boolp(notify["unstable"], false)
  xml.notifyFailure boolp(notify["failure"], false)
  xml.notifyBackToNormal boolp(notify["back-to-normal"], false)
  xml.notifyRepeatedFailures boolp(notify["repeated-failure"], false)

  xml.includeTestSummary boolp(pdef["include-test-summary"], false)
  xml.showCommitList boolp(notify["show-commit-list"], false)

  xml.includeCustomMessage !!pdef["custom-message"]
  xml.customMessage pdef["custom-message"]
end
translate_slave_utilization_property(xml, pdef) click to toggle source
# File lib/cigale/property/slave-utilization.rb, line 3
def translate_slave_utilization_property (xml, pdef)
  xml.needsExclusiveAccessToNode (false == pdef["single-instance-per-slave"])
  xml.slaveUtilizationPercentage pdef["slave-percentage"] || 0
  xml.singleInstancePerSlave boolp(pdef["single-instance-per-slave"], false)
end
translate_throttle_property(xml, pdef) click to toggle source
# File lib/cigale/property/throttle.rb, line 3
def translate_throttle_property (xml, pdef)
  xml.maxConcurrentPerNode 0
  xml.maxConcurrentTotal pdef["max-total"]
  xml.throttleEnabled true
  xml.categories do
    for cat in pdef["categories"]
      xml.string cat
    end
  end
  xml.throttleOption
  xml.configVersion 1
end
translate_zeromq_event_property(xml, pdef) click to toggle source
# File lib/cigale/property/zeromq-event.rb, line 3
def translate_zeromq_event_property (xml, pdef)
  xml.enabled true
end