Module: Cigale::Wrapper

Defined in:
lib/cigale/wrapper.rb,
lib/cigale/wrapper/xvfb.rb,
lib/cigale/wrapper/xvnc.rb,
lib/cigale/wrapper/locks.rb,
lib/cigale/wrapper/rbenv.rb,
lib/cigale/wrapper/inject.rb,
lib/cigale/wrapper/ci-skip.rb,
lib/cigale/wrapper/release.rb,
lib/cigale/wrapper/timeout.rb,
lib/cigale/wrapper/env-file.rb,
lib/cigale/wrapper/logstash.rb,
lib/cigale/wrapper/mongo-db.rb,
lib/cigale/wrapper/exclusion.rb,
lib/cigale/wrapper/ansi-color.rb,
lib/cigale/wrapper/env-script.rb,
lib/cigale/wrapper/logfilesize.rb,
lib/cigale/wrapper/custom-tools.rb,
lib/cigale/wrapper/job-log-logger.rb,
lib/cigale/wrapper/port-allocator.rb,
lib/cigale/wrapper/live-screenshot.rb,
lib/cigale/wrapper/android-emulator.rb,
lib/cigale/wrapper/inject-passwords.rb,
lib/cigale/wrapper/delivery-pipeline.rb,
lib/cigale/wrapper/matrix-tie-parent.rb,
lib/cigale/wrapper/workspace-cleanup.rb,
lib/cigale/wrapper/credentials-binding.rb,
lib/cigale/wrapper/config-file-provider.rb,
lib/cigale/wrapper/m2-repository-cleanup.rb,
lib/cigale/wrapper/ssh-agent-credentials.rb,
lib/cigale/wrapper/inject-ownership-variables.rb

Defined Under Namespace

Classes: CustomWrapper

Instance Method Summary collapse

Instance Method Details

#ciskipclass(clazz) ⇒ Object



14
15
16
17
18
19
# File 'lib/cigale/wrapper/ci-skip.rb', line 14

def ciskipclass (clazz)
  return {
    :pluginid => "ci-skip",
    :"ruby-class" => clazz,
  }
end

#rbenvclass(clazz) ⇒ Object



21
22
23
24
25
26
# File 'lib/cigale/wrapper/rbenv.rb', line 21

def rbenvclass (clazz)
  return {
    :pluginid => "rbenv",
    :"ruby-class" => clazz,
  }
end

#translate_android_emulator_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cigale/wrapper/android-emulator.rb', line 3

def translate_android_emulator_wrapper (xml, wdef)
  if avd = wdef["avd"]
    xml.avdName avd
  else
    xml.osVersion wdef["os"]
    xml.screenDensity "mdpi"
    xml.screenResolution "WVGA"
    xml.deviceLocale "en_US"
    xml.targetAbi wdef["target-abi"]
    xml.sdCardSize wdef["sd-card"]
  end

  hardprops = (wdef["hardware-properties"] || {})

  if hardprops.empty?
    xml.hardwareProperties
  else
    xml.hardwareProperties do
      hardprops.each do |key, value|
        xml.tag! "hudson.plugins.android__emulator.AndroidEmulator_-HardwareProperty" do
          xml.key key
          xml.value value
        end
      end
    end
  end

  xml.wipeData boolp(wdef["wipe"], false)
  xml.showWindow boolp(wdef["show-window"], false)
  xml.useSnapshots boolp(wdef["snapshot"], false)
  xml.deleteAfterBuild boolp(wdef["delete"], false)
  xml.startupDelay wdef["startup-delay"] || 0
  xml.commandLineOptions wdef["commandline-options"]
  xml.executable wdef["exe"]
end

#translate_ansi_color_wrapper(xml, wdef) ⇒ Object



3
4
5
# File 'lib/cigale/wrapper/ansi-color.rb', line 3

def translate_ansi_color_wrapper (xml, wdef)
  xml.colorMapName wdef["color-map"] || "xterm"
end

#translate_ci_skip_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/cigale/wrapper/ci-skip.rb', line 3

def translate_ci_skip_wrapper (xml, wdef)
  xml.tag! "ruby-proxy-object" do
    xml.tag! "ruby-object", ciskipclass("Jenkins::Tasks::BuildWrapperProxy") do
      xml.pluginid "ci-skip", ciskipclass("String")
      xml.object ciskipclass("CiSkipWrapper") do
        xml.ci__skip ciskipclass("NilClass")
      end
    end
  end
end

#translate_config_file_provider_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cigale/wrapper/config-file-provider.rb', line 3

def translate_config_file_provider_wrapper (xml, wdef)
  xml.tag! "org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper", :plugin => "config-file-provider" do
    xml.managedFiles do
      for file in wdef["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_credentials_binding_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cigale/wrapper/credentials-binding.rb', line 3

def translate_credentials_binding_wrapper (xml, wdef)
  @credentials_binding_classes ||= {
    "zip-file" => "org.jenkinsci.plugins.credentialsbinding.impl.ZipFileBinding",
    "file" => "org.jenkinsci.plugins.credentialsbinding.impl.FileBinding",
    "username-password" => "org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordBinding",
    "username-password-separated" => "org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding",
    "text" => "org.jenkinsci.plugins.credentialsbinding.impl.StringBinding",
  }

  xml.bindings do
    for binding in toa wdef
      k, v = first_pair(binding)
      clazz = @credentials_binding_classes[k] or raise "Unknown credentials binding class: #{k}"

      xml.tag! clazz do
        case k
        when "username-password-separated"
          xml.usernameVariable v["username"]
          xml.passwordVariable v["password"]
        else
          xml.variable v["variable"]
        end
        xml.credentialsId v["credential-id"]
      end
    end
  end
end

#translate_custom_tools_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cigale/wrapper/custom-tools.rb', line 3

def translate_custom_tools_wrapper (xml, wdef)
  xml.selectedTools do
    for tool in wdef["tools"]
      xml.tag! "com.cloudbees.jenkins.plugins.customtools.CustomToolInstallWrapper_-SelectedTool" do
        xml.name tool
      end
    end
  end

  xml.multiconfigOptions do
    xml.skipMasterInstallation wdef["skip-master-install"]
  end
  xml.convertHomesToUppercase wdef["convert-homes-to-upper"]
end

#translate_delivery_pipeline_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
# File 'lib/cigale/wrapper/delivery-pipeline.rb', line 3

def translate_delivery_pipeline_wrapper (xml, wdef)
  xml.tag! "se.diabol.jenkins.pipeline.PipelineVersionContributor" do
    xml.versionTemplate wdef["version-template"]
    xml.updateDisplayName boolp(wdef["set-display-name"], false)
  end
end

#translate_env_file_wrapper(xml, wdef) ⇒ Object



3
4
5
# File 'lib/cigale/wrapper/env-file.rb', line 3

def translate_env_file_wrapper (xml, wdef)
  xml.filePath wdef["properties-file"]
end

#translate_env_script_wrapper(xml, wdef) ⇒ Object



3
4
5
6
# File 'lib/cigale/wrapper/env-script.rb', line 3

def translate_env_script_wrapper (xml, wdef)
  xml.script wdef["script-content"]
  xml.onlyRunOnParent wdef["only-run-on-parent"]
end

#translate_exclusion_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/cigale/wrapper/exclusion.rb', line 3

def translate_exclusion_wrapper (xml, wdef)
  xml.tag! "org.jvnet.hudson.plugins.exclusion.IdAllocator", :plugin => "Exclusion" do
    xml.ids do
      for res in wdef["resources"]
        xml.tag! "org.jvnet.hudson.plugins.exclusion.DefaultIdType" do
          xml.name res.upcase
        end
      end
    end
  end
end

#translate_inject_ownership_variables_wrapper(xml, wdef) ⇒ Object



3
4
5
6
# File 'lib/cigale/wrapper/inject-ownership-variables.rb', line 3

def translate_inject_ownership_variables_wrapper (xml, wdef)
  xml.injectNodeOwnership wdef["node-variables"]
  xml.injectJobOwnership wdef["job-variables"]
end

#translate_inject_passwords_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/cigale/wrapper/inject-passwords.rb', line 3

def translate_inject_passwords_wrapper (xml, wdef)
  xml.injectGlobalPasswords true
  xml.maskPasswordParameters true
  xml.passwordEntries do
    for pass in wdef["job-passwords"]
      xml.EnvInjectPasswordEntry do
        xml.name pass["name"]
        xml.value pass["password"]
      end
    end
  end
end

#translate_inject_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/cigale/wrapper/inject.rb', line 3

def translate_inject_wrapper (xml, wdef)
  xml.info do
    val = wdef["properties-file-path"] and xml.propertiesFilePath val
    val = wdef["properties-content"] and xml.propertiesContent val
    val = wdef["script-file-path"] and xml.scriptFilePath val
    val = wdef["script-content"] and xml.scriptContent val
    val = wdef["groovy-script-content"] and xml.groovyScriptContent val
    xml.loadFilesFromMaster boolp(wdef["load-files-from-master"], false)
  end
end

#translate_job_log_logger_wrapper(xml, wdef) ⇒ Object



3
4
5
# File 'lib/cigale/wrapper/job-log-logger.rb', line 3

def translate_job_log_logger_wrapper (xml, wdef)
  xml.suppressEmpty wdef["suppress-empty"]
end

#translate_live_screenshot_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
# File 'lib/cigale/wrapper/live-screenshot.rb', line 3

def translate_live_screenshot_wrapper (xml, wdef)
  xml.tag! "org.jenkinsci.plugins.livescreenshot.LiveScreenshotBuildWrapper" do
    xml.fullscreenFilename wdef["full-size"] || "screenshot.png"
    xml.thumbnailFilename wdef["thumbnail"] || "screenshot-thumb.png"
  end
end

#translate_locks_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cigale/wrapper/locks.rb', line 3

def translate_locks_wrapper (xml, wdef)
  wdef = toa wdef
  return if wdef.empty?

  xml.tag! "hudson.plugins.locksandlatches.LockWrapper" do
    xml.locks do
      for lock in wdef
        xml.tag! "hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig" do
          xml.name lock
        end
      end
    end
  end
end

#translate_logfilesize_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/cigale/wrapper/logfilesize.rb', line 3

def translate_logfilesize_wrapper (xml, wdef)
  xml.tag! "hudson.plugins.logfilesizechecker.LogfilesizecheckerWrapper", :plugin => "logfilesizechecker" do
    xml.setOwn boolp(wdef["set-own"], false)
    xml.maxLogSize wdef["size"] || 128
    xml.failBuild boolp(wdef["fail"], false)
  end
end

#translate_logstash_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cigale/wrapper/logstash.rb', line 3

def translate_logstash_wrapper (xml, wdef)
  xml.tag! "jenkins.plugins.logstash.LogstashBuildWrapper", :plugin => "[email protected]" do
    xml.useRedis wdef["use-redis"]

    if wdef["use-redis"] == true
      redis = (wdef["redis"] || {})
      xml.redis do
        xml.host redis["host"] || "localhost"
        xml.port redis["port"] || 6379
        xml.numb redis["database-number"] || 0
        xml.pass redis["database-password"]
        xml.dataType redis["data-type"] || "list"
        xml.key redis["key"] || "logstash"
      end
    end
  end
end

#translate_m2_repository_cleanup_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cigale/wrapper/m2-repository-cleanup.rb', line 3

def translate_m2_repository_cleanup_wrapper (xml, wdef)
  xml.tag! "hudson.plugins.m2__repo__reaper.M2RepoReaperWrapper", :plugin => "m2-repo-reaper" do

    patterns = toa wdef["patterns"]
    if patterns.empty?
      xml.artifactPatterns
      xml.patterns
    else
      xml.artifactPatterns patterns.join(",")

      xml.patterns do
        for pattern in patterns
          xml.string pattern
        end
      end
    end
  end
end

#translate_matrix_tie_parent_wrapper(xml, wdef) ⇒ Object



3
4
5
# File 'lib/cigale/wrapper/matrix-tie-parent.rb', line 3

def translate_matrix_tie_parent_wrapper (xml, wdef)
  xml.labelName wdef["node"]
end

#translate_mongo_db_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/cigale/wrapper/mongo-db.rb', line 3

def translate_mongo_db_wrapper (xml, wdef)
  xml.tag! "org.jenkinsci.plugins.mongodb.MongoBuildWrapper", :plugin => "mongodb" do
    xml.mongodbName wdef["name"]
    xml.port wdef["port"]
    xml.dbpath wdef["data-directory"]
    xml.parameters wdef["startup-params"]
    xml.startTimeout wdef["start-timeout"] || 0
  end
end

#translate_port_allocator_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/cigale/wrapper/port-allocator.rb', line 3

def translate_port_allocator_wrapper (xml, wdef)
  xml.ports do
    names = wdef["names"] || [wdef["name"]]

    for name in names
      xml.tag! "org.jvnet.hudson.plugins.port__allocator.DefaultPortType" do
        xml.name name
      end
    end
  end
end

#translate_rbenv_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cigale/wrapper/rbenv.rb', line 3

def translate_rbenv_wrapper (xml, wdef)
  xml.tag! "ruby-proxy-object" do
    xml.tag! "ruby-object", rbenvclass("Jenkins::Tasks::BuildWrapperProxy") do
      xml.pluginid "rbenv", rbenvclass("String")
      xml.object rbenvclass("RbenvWrapper") do
        xml.gem__list "bundler,rake", rbenvclass("String")
        xml.rbenv__root "$HOME/.rbenv", rbenvclass("String")
        xml.rbenv__repository "https://github.com/sstephenson/rbenv.git", rbenvclass("String")
        xml.rbenv__revision "master", rbenvclass("String")
        xml.ruby__build__repository "https://github.com/sstephenson/ruby-build.git", rbenvclass("String")
        xml.ruby__build__revision "master", rbenvclass("String")
        xml.version wdef["ruby-version"] || "1.9.3-p484", rbenvclass("String")
        xml.ignore__local__version (wdef["ignore-local-version"] == true ? rbenvclass("trueClass") : rbenvclass("falseClass"))
      end
    end
  end
end

#translate_release_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cigale/wrapper/release.rb', line 3

def translate_release_wrapper (xml, wdef)
  xml.doNotKeepLog !wdef["keep-forever"]
  xml.overrideBuildParameters false
  xml.releaseVersionTemplate
  xml.parameterDefinitions do
    for param in wdef["parameters"]
      ptype, pspec = asplode param
      translate("parameter", xml, ptype, pspec)
    end
  end

  translate_builders xml, "postSuccessfulBuildSteps", wdef["post-success"]
end

#translate_ssh_agent_credentials_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/cigale/wrapper/ssh-agent-credentials.rb', line 3

def translate_ssh_agent_credentials_wrapper (xml, wdef)
  users = wdef["users"] || [wdef["user"]]
  if users.size > 1
    xml.credentialIds do
      for user in users
        xml.string user
      end
    end
  else
    for user in users
      xml.user user
    end
  end
end

#translate_timeout_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cigale/wrapper/timeout.rb', line 3

def translate_timeout_wrapper (xml, wdef)
  use_strategy = wdef.has_key?("timeout") && %w(no-activity likely-stuck absolute).include?(wdef["type"])

  xml.timeoutMinutes wdef["timeout"] || 3

  timeoutvar = wdef["timeout-var"] and xml.timeoutEnvVar timeoutvar
  xml.failBuild wdef["fail"]
  xml.writingDescription boolp(wdef["write-description"], false)

  xml.timeoutPercentage wdef["elastic-percentage"] || 0
  xml.timeoutMinutesElasticDefault wdef["elastic-default-timeout"] || 3

  case wdef["type"]
  when "absolute"
    xml.timeoutType "absolute"
  when "elastic"
    xml.timeoutType "elastic"
  when "likely-stuck"
    xml.timeoutType "likelyStuck"
  end
end

#translate_workspace_cleanup_wrapper(xml, wdef) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/cigale/wrapper/workspace-cleanup.rb', line 2

def translate_workspace_cleanup_wrapper (xml, wdef)
  # cf. publisher/workspace-cleanup.rb
  translate_wscleanup_base xml, wdef

  xml.cleanupParameter wdef["cleanup-parameter"]
  ed = wdef["external-delete"] and xml.externalDelete ed
end

#translate_wrappers(xml, wrappers) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/cigale/wrapper.rb', line 72

def translate_wrappers (xml, wrappers)
  wrappers = toa wrappers
  wrappers = toa(wrappers).reject do |w|
    type, spec = asplode w
    case
    when type == "locks" && (toa spec).empty?
      true
    else
      false
    end
  end

  if wrappers.empty?
    return xml.buildWrappers
  end

  xml.buildWrappers do
    for w in wrappers
      type, spec = asplode w
      translate("wrapper", xml, type, spec)
    end
  end
end

#translate_xvfb_wrapper(xml, wdef) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/cigale/wrapper/xvfb.rb', line 3

def translate_xvfb_wrapper (xml, wdef)
  xml.installationName wdef["installation-name"] || "default"
  xml.autoDisplayName boolp(wdef["auto-display-name"], false)
  display_name = wdef["display-name"] and xml.displayName display_name
  xml.assignedLabels wdef["assigned-labels"]
  xml.parallelBuild boolp(wdef["parallel-builds"], false)
  xml.timeout wdef["timeout"] || 0
  xml.screen wdef["screen"] || "1024x768x24"
  xml.displayNameOffset wdef["display-name-offset"] || 1
  xml.additionalOptions wdef["additional-options"]
  xml.debug boolp(wdef["debug"], false)
  xml.shutdownWithBuild boolp(wdef["shutdown-with-build"], false)
end

#translate_xvnc_wrapper(xml, wdef) ⇒ Object



3
4
5
6
# File 'lib/cigale/wrapper/xvnc.rb', line 3

def translate_xvnc_wrapper (xml, wdef)
  xml.takeScreenshot wdef["screenshot"]
  xml.useXauthority wdef["xauthority"]
end

#wrapper_classesObject



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
# File 'lib/cigale/wrapper.rb', line 36

def wrapper_classes
  @wrapper_classes ||= {
    "mongo-db" => CustomWrapper.new,
    "rbenv" => CustomWrapper.new,
    "m2-repository-cleanup" => CustomWrapper.new,
    "logstash" => CustomWrapper.new,
    "logfilesize" => CustomWrapper.new,
    "exclusion" => CustomWrapper.new,
    "config-file-provider" => CustomWrapper.new,
    "ci-skip" => CustomWrapper.new,
    "delivery-pipeline" => CustomWrapper.new,
    "live-screenshot" => CustomWrapper.new,

    "timeout" => "hudson.plugins.build__timeout.BuildTimeoutWrapper",
    "inject-passwords" => "EnvInjectPasswordWrapper",
    "inject" => "EnvInject",
    "port-allocator" => "org.jvnet.hudson.plugins.port__allocator.PortAllocator",
    "android-emulator" => "hudson.plugins.android__emulator.AndroidEmulator",
    "ssh-agent-credentials" => "com.cloudbees.jenkins.plugins.sshagent.SSHAgentBuildWrapper",
    "inject-ownership-variables" => "com.synopsys.arc.jenkins.plugins.ownership.wrappers.OwnershipBuildWrapper",
    "inject" => "EnvInjectBuildWrapper",
    "env-script" => "com.lookout.jenkins.EnvironmentScript",
    "env-file" => "hudson.plugins.envfile.EnvFileBuildWrapper",
    "matrix-tie-parent" => "matrixtieparent.BuildWrapperMtp",
    "locks" => CustomWrapper.new,
    "xvfb" => "org.jenkinsci.plugins.xvfb.XvfbBuildWrapper",
    "xvnc" => "hudson.plugins.xvnc.Xvnc",
    "credentials-binding" => "org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper",
    "job-log-logger" => "org.jenkins.ci.plugins.jobloglogger.JobLogLoggerBuildWrapper",
    "custom-tools" => "com.cloudbees.jenkins.plugins.customtools.CustomToolInstallWrapper",
    "release" => "hudson.plugins.release.ReleaseWrapper",
    "ansi-color" => ["hudson.plugins.ansicolor.AnsiColorBuildWrapper", :plugin => "[email protected]"],
    "workspace-cleanup" => ["hudson.plugins.ws__cleanup.PreBuildCleanup", :plugin => "[email protected]"],
  }
end