81 lines
2.4 KiB
Groovy
81 lines
2.4 KiB
Groovy
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<String> paths) {
|
|
ArrayList<SparseCheckoutPath> sparsecheckoutpaths = new ArrayList<SparseCheckoutPath>()
|
|
for (path in paths) {
|
|
sparsecheckoutpaths.add(new SparseCheckoutPath(path))
|
|
}
|
|
return new SparseCheckoutPaths(sparsecheckoutpaths)
|
|
}
|
|
|
|
def gitCheckout(String gitURL, String revision, String targetDir, String repoRoot = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
|
reporootenv = env.REPO_ROOT
|
|
if (reporootenv != null && repoRoot != "") {
|
|
reporootpath = "${reporootenv.trim()}/${repoRoot}"
|
|
} 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
|