import hudson.plugins.git.* import hudson.plugins.git.extensions.* import hudson.plugins.git.extensions.impl.* clh = load("${autobuilder.commonscripts()}/commandline/commandline.groovy") String getGitInfo(String workingSetRootPath) { dir(workingSetRootPath) { return clh.getCommandOutput('git rev-parse HEAD') } } @NonCPS def SparseCheckoutPaths sparsecheckoutconfig(ArrayList paths) { ArrayList sparsecheckoutpaths = new ArrayList() for (path in paths) { sparsecheckoutpaths.add(new SparseCheckoutPath(path)) } return new SparseCheckoutPaths(sparsecheckoutpaths) } def guessreporoot(componentURL) { if (!env.REPO_ROOT || env.REPO_ROOT.size() == 0) { return '' } def guess = componentURL.replaceFirst(/.*\/(.*).git/, '$1') def reporoot = "${REPO_ROOT}/${guess}" echo "Guessing reporoot is: ${reporoot}" return reporoot } def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { reporootenv = env.REPO_ROOT if (reporootenv != null && repoRootSuffix != "") { reporootpath = "${reporootenv.trim()}/${repoRootSuffix}" echo "Using release repo: ${reporootpath}" } else { reporootpath = "" echo "To improve Git performance: Define the REPO_ROOT enviroment to a path where a cache of git repositories can be placed on this slave" } checkout([ $class: 'GitSCM', userRemoteConfigs: [ [url: gitURL] ], branches: [ [name: revision] ], doGenerateSubmoduleConfigurations: false, extensions: [ [$class: 'GitLFSPull'], [$class: 'CleanBeforeCheckout'], [$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120], [$class: 'CheckoutOption', timeout: 120], [$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir], sparsecheckoutconfig(sparseitemlist) ], submoduleCfg: [], ]) } String getSHAFromVersion(String versionFolder) { dir (versionFolder) { srcRevision = readFile("gitrevision.txt").trim() } return srcRevision } boolean checkAllVersionsAgree(java.util.LinkedHashMap versions) { def keys = versions.keySet() if (keys.size() < 1) { return false } if (keys.size() == 1) { return true } else { version = "" for (key in keys) { nextversion = versions.get(key) if (version == "") { version = nextversion } if (nextversion != version) { return false } } } return true } return this