module Cigale::SCM

Public Instance Methods

git_browser_classes() click to toggle source
# File lib/cigale/scm/git.rb, line 156
def git_browser_classes
  @git_browser_classes ||= {
    "githubweb" => "hudson.plugins.git.browser.GithubWeb",
    "rhodecode" => "hudson.plugins.git.browser.RhodeCode",
    "stash" => "hudson.plugins.git.browser.Stash",
    "gitlab" => "hudson.plugins.git.browser.GitLab",
  }
end
hg_browser_classes() click to toggle source
# File lib/cigale/scm/hg.rb, line 31
def hg_browser_classes
  @hg_browser_classes ||= {
    "hgweb" => "hudson.plugins.mercurial.browser.HgWeb",
  }
end
scm_classes() click to toggle source
# File lib/cigale/scm.rb, line 11
def scm_classes
  @scm_classes ||= {
    "nil" => "hudson.scm.NullSCM",
    "git" => "hudson.plugins.git.GitSCM",
    "repo" => "hudson.plugins.repo.RepoScm",
    "tfs" => "hudson.plugins.tfs.TeamFoundationServerScm",
    "workspace" => "hudson.plugins.cloneworkspace.CloneWorkspaceSCM",
    "hg" => "hudson.plugins.mercurial.MercurialSCM",
    "store" => "org.jenkinsci.plugins.visualworks_store.StoreSCM",
    "svn" => "hudson.scm.SubversionSCM"
  }
end
svn_workspace_updaters() click to toggle source
# File lib/cigale/scm/svn.rb, line 65
def svn_workspace_updaters
  @svn_workspace_updaters ||= {
    "update" => "hudson.scm.subversion.UpdateUpdater",
    "wipeworkspace" => "hudson.scm.subversion.CheckoutUpdater",
  }
end
translate_git_scm(xml, sdef) click to toggle source
# File lib/cigale/scm/git.rb, line 3
def translate_git_scm (xml, sdef)
  xml.configVersion 2

  xml.userRemoteConfigs do
    if remotes = sdef["remotes"]
      for r in remotes
        remote_name, rdef = first_pair(r)
        xml.tag! "hudson.plugins.git.UserRemoteConfig" do
          xml.name remote_name
          xml.refspec rdef["refspec"] || "+refs/heads/*:refs/remotes/#{remote_name}/*"
          xml.url rdef["url"]
          cri = rdef["credentials-id"] and xml.credentialsId cri
        end
      end
    else
      xml.tag! "hudson.plugins.git.UserRemoteConfig" do
        remote_name = sdef["name"] || "origin"
        xml.name remote_name
        xml.refspec sdef["refspec"] || "+refs/heads/*:refs/remotes/#{remote_name}/*"
        xml.url sdef["url"]
        cri = sdef["credentials-id"] and xml.credentialsId cri
      end
    end
  end

  xml.branches do
    branches = sdef["branches"] || ["**"]
    for branch in branches
      xml.tag! "hudson.plugins.git.BranchSpec" do
        xml.name branch
      end
    end
  end

  xml.excludedUsers

  if mopts = sdef["merge"]
    xml.userMergeOptions do
      xml.mergeRemote mopts["remote"]
      xml.mergeTarget mopts["branch"]
      xml.mergeStrategy mopts["strategy"]
      xml.fastForwardMode mopts["fast-forward-mode"]
    end
  end

  xml.buildChooser :class => "hudson.plugins.git.util.DefaultBuildChooser"

  subdef = sdef["submodule"]

  if subdef.nil?
    xml.disableSubmodules false
    xml.recursiveSubmodules false
  end
  xml.doGenerateSubmoduleConfigurations false

  xml.authorOrCommitter false
  wipe = boolp(sdef["wipe"], true)
  xml.wipeOutWorkspace wipe
  xml.pruneBranches false
  xml.remotePoll false
  xml.gitTool "Default"
  xml.submoduleCfg :class => "list"
  xml.relativeTargetDir sdef["relative-target-dir"]
  xml.reference
  xml.gitConfigName
  xml.gitConfigEmail
  xml.skipTag boolp(sdef["skip-tag"], false)
  xml.scmName
  xml.useShallowClone boolp(sdef["shallow-clone"], false)
  xml.ignoreNotifyCommit boolp(sdef["ignore-notify"], false)

  lb = sdef["local-branch"] and xml.localBranch lb

  xml.extensions do
    if val = sdef["changelog-against"]
      xml.tag! "hudson.plugins.git.extensions.impl.ChangelogToBranch" do
        xml.options do
          xml.compareRemote val["remote"]
          xml.compareTarget val["branch"]
        end
      end
    end

    timeout = sdef["timeout"] and xml.tag! "hudson.plugins.git.extensions.impl.CheckoutOption" do
      xml.timeout timeout
    end

    subdef and xml.tag! "hudson.plugins.git.extensions.impl.SubmoduleOption" do
      xml.disableSubmodules subdef["disable"]
      xml.recursiveSubmodules subdef["recursive"]
      xml.trackingSubmodules subdef["tracking"]
      xml.timeout subdef["timeout"] || 10
    end

    sdef["force-polling-using-workspace"] and xml.tag! "hudson.plugins.git.extensions.impl.DisableRemotePoll"

    exclRegions = toa sdef["excluded-regions"]
    inclRegions = toa sdef["included-regions"]
    unless exclRegions.empty? && inclRegions.empty?
      xml.tag! "hudson.plugins.git.extensions.impl.PathRestriction" do
        exclRegions.empty? or xml.tag! "excludedRegions", exclRegions.join("\n")
        inclRegions.empty? or xml.tag! "includedRegions", inclRegions.join("\n")
      end
    end

    if cl = sdef["clean"]
      case cl
      when Hash
        cl["after"] and xml.tag! "hudson.plugins.git.extensions.impl.CleanCheckout"
        cl["before"] and xml.tag! "hudson.plugins.git.extensions.impl.CleanBeforeCheckout"
      else
        xml.tag! "hudson.plugins.git.extensions.impl.CleanCheckout"
      end
    end

    if sch = sdef["sparse-checkout"]
      xml.tag! "hudson.plugins.git.extensions.impl.SparseCheckoutPaths" do
        xml.sparseCheckoutPaths do
          for path in sch["paths"]
            xml.tag! "hudson.plugins.git.extensions.impl.SparseCheckoutPath" do
              xml.path path
            end
          end
        end
      end
    end

    if ign = sdef["ignore-commits-with-messages"]
      for pattern in ign
        xml.tag! "hudson.plugins.git.extensions.impl.MessageExclusion" do
          xml.excludedMessage pattern
        end
      end
    end

    if reldir = sdef["relative-target-dir"]
      xml.tag! "hudson.plugins.git.extensions.impl.RelativeTargetDirectory" do
        xml.relativeTargetDir reldir
      end
    end

    wipe and xml.tag! "hudson.plugins.git.extensions.impl.WipeWorkspace"
  end

  if browser = sdef["browser"]
    bclass = git_browser_classes[browser] or raise "Unknown git browser type #{browser}"
    xml.browser :class => bclass do
      url = sdef["browser-url"] and xml.url url
      ver = sdef["browser-version"] and xml.version ver
    end
  end
end
translate_hg_scm(xml, sdef) click to toggle source
# File lib/cigale/scm/hg.rb, line 3
def translate_hg_scm (xml, sdef)
  xml.source sdef["url"]
  if cid = sdef["credentials-id"]
    xml.credentialsId cid
  end
  xml.revisionType (sdef["revision-type"] || "BRANCH").upcase
  xml.revision sdef["revision"] || "default"
  if sub = sdef["subdir"]
    xml.subdir sub
  end
  xml.clean sdef["clean"] || false
  if sdef["modules"]
    xml.modules toa(sdef["modules"]).join " "
  else
    xml.modules
  end
  xml.disableChangeLog sdef["disable-changelog"] || false

  if browser = sdef["browser"]
    bclass = hg_browser_classes[browser] or raise "Unknown hg browser type #{browser}"
    xml.browser :class => bclass do
      if val = sdef["browser-url"]
        xml.url val
      end
    end
  end
end
translate_repo_scm(xml, sdef) click to toggle source
# File lib/cigale/scm/repo.rb, line 3
def translate_repo_scm (xml, sdef)
  xml.manifestRepositoryUrl sdef["manifest-url"]
  xml.manifestBranch sdef["manifest-branch"]
  xml.manifestFile sdef["manifest-file"]
  xml.manifestGroup sdef["manifest-group"]
  xml.destinationDir sdef["destination-dir"]
  xml.repoUrl sdef["repo-url"]
  xml.mirrorDir sdef["mirror-dir"]
  xml.jobs sdef["jobs"]
  xml.currentBranch sdef["current-branch"]
  xml.quiet sdef["quiet"]
  xml.localManifest sdef["local-manifest"]
end
translate_scms(xml, scms, multi=false) click to toggle source
# File lib/cigale/scm.rb, line 24
def translate_scms (xml, scms, multi=false)
  scms = toa scms
  if scms.empty?
    return xml.scm :class => scm_classes["nil"]
  end

  if scms.size > 1 and not multi
    return xml.scm :class => "org.jenkinsci.plugins.multiplescms.MultiSCM" do
      xml.scms do
        translate_scms(xml, scms, true)
      end
    end
  end

  for s in scms
    type, spec = asplode s

    case type
    when "raw"
      insert_raw xml, spec
    else
      clazz = scm_classes[type]
      raise "Unknown scm type: #{type}" unless clazz

      method = method_for_translate("scm", type)

      xml.scm :class => clazz do
        self.send method, xml, spec
      end
    end
  end
end
translate_store_scm(xml, sdef) click to toggle source
# File lib/cigale/scm/store.rb, line 3
def translate_store_scm (xml, sdef)
  xml.scriptName sdef["script"]
  xml.repositoryName sdef["repository"]
  xml.pundles do
    for p in sdef["pundles"]
      xml.tag! "org.jenkinsci.plugins.visualworks_store.PundleSpec" do
        type, name = first_pair(p)
        xml.name name
        xml.pundleType type.upcase
      end
    end
  end
  xml.versionRegex sdef["version-regex"]
  xml.minimumBlessingLevel sdef["minimum-blessing"]
  if pbf = sdef["parcel-builder-file"]
    xml.generateParcelBuilderInputFile true
    xml.parcelBuilderInputFilename pbf
  end
end
translate_svn_scm(xml, sdef) click to toggle source
# File lib/cigale/scm/svn.rb, line 3
def translate_svn_scm (xml, sdef)
  if vu = sdef["viewvc-url"]
    xml.browser :class => "hudson.scm.browsers.ViewSVN" do
      xml.url vu
    end
  end

  xml.locations do
    if repos = sdef["repos"]
      for r in repos
        xml.tag! "hudson.scm.SubversionSCM_-ModuleLocation" do
          xml.remote r["url"]
          xml.local r["basedir"] || "."
          if cri = r["credentials-id"]
            xml.credentialsId cri
          end
          xml.depthOption r["repo-depth"] || "infinity"
          xml.ignoreExternalsOption r["ignore-externals"] || false
        end
      end
    else
      xml.tag! "hudson.scm.SubversionSCM_-ModuleLocation" do
        xml.remote sdef["url"]
        xml.local "."
        if cri = sdef["credentials-id"]
          xml.credentialsId cri
        end
        xml.depthOption sdef["repo-depth"] || "infinity"
        xml.ignoreExternalsOption sdef["ignore-externals"] || false
      end
    end
  end # locations

  if upd = sdef["workspaceupdater"]
    uclass = svn_workspace_updaters[upd] or raise "Unknown svn repo updater: #{upd}"
    xml.workspaceUpdater :class => uclass
  end

  if exclRegions = sdef["excluded-regions"]
    xml.excludedRegions exclRegions.join("\n")
  end

  if inclRegions = sdef["included-regions"]
    xml.includedRegions inclRegions.join("\n")
  end

  if exclUsers = sdef["excluded-users"]
    xml.excludedUsers exclUsers.join("\n")
  end

  if exclProp = sdef["exclusion-revprop-name"]
    xml.excludedRevprop exclProp
  end

  if exclCommits = sdef["excluded-commit-messages"]
    xml.excludedCommitMessages exclCommits.join("\n")
  end

  xml.ignoreDirPropChanges sdef["ignore-property-changes-on-directories"] || false
  xml.filterChangelog sdef["filter-changelog"] || false
end
translate_tfs_scm(xml, sdef) click to toggle source
# File lib/cigale/scm/tfs.rb, line 3
def translate_tfs_scm (xml, sdef)
  xml.serverUrl sdef["server-url"]
  xml.projectPath sdef["project-path"]
  xml.localPath sdef["local-path"]
  xml.workspaceName sdef["workspace"]
  xml.userPassword sdef["password"]
  xml.userName sdef["login"]
  xml.useUpdate sdef["use-update"]

  if sdef.has_key? "web-access"
    wa = sdef["web-access"]
    bclass = "hudson.plugins.tfs.browsers.TeamSystemWebAccessBrowser"

    if wa
      xml.repositoryBrowser :class => bclass do
        for u in toa wa
          xml.url u["web-url"]
        end
      end
    else
      xml.repositoryBrowser :class => bclass
    end
  end
end
translate_workspace_scm(xml, sdef) click to toggle source
# File lib/cigale/scm/workspace.rb, line 3
def translate_workspace_scm (xml, sdef)
  xml.parentJobName sdef["parent-job"]
  xml.criteria sdef["criteria"]
end