Always create a repo_root copy of a repo when necessary - in order to speed up jobs

This commit is contained in:
Dan Hawkins 2019-03-29 08:44:12 +00:00
commit 4942d1bc6b

View file

@ -29,15 +29,50 @@ def guessreporoot(componentURL) {
return reporoot
}
def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
reporootenv = env.REPO_ROOT
if (reporootenv != null && repoRootSuffix != "") {
reporootpath = "${reporootenv.trim()}/${repoRootSuffix}"
echo "Using release repo: ${reporootpath}"
} else {
reporootpath = ""
def String uniquereporootname(String gitURL) {
def uniquename = gitURL.replaceAll("[^A-Za-z0-9]", "_")
echo "Unique reporoot name for URL: ${gitURL} is: ${uniquename}"
return uniquename
}
// The REPO_ROOT is a folder where a cache of git checkouts can be kept - each subfolder name is unique to a particular git repo
def String checkouttoreporoot(String gitURL) {
def String reporootsubfolder
def String reporootenv = env.REPO_ROOT
if (!reporootenv) {
reporootsubfolder = ""
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"
}
} else {
def reporootname = uniquereporootname(gitURL)
def reporootsubfolder = "${reporootenv}/${reporootname}"
if (!fileExists(reporootsubfolder)) {
echo "Checking out ${gitURL} to ${reporootname}"
checkout([
$class: 'GitSCM',
userRemoteConfigs: [
[url: gitURL]
],
branches: [
[name: 'origin/master']
],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'GitLFSPull'],
[$class: 'CleanBeforeCheckout'],
[$class: 'CheckoutOption', timeout: 180],
[$class: 'RelativeTargetDirectory', relativeTargetDir: reporootsubfolder],
],
submoduleCfg: [],
])
} else {
echo "Found ${gitURL} checked out at ${reporootname}"
}
return reporootsubfolder
}
def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
def reporootpath = checkouttoreporoot(gitURL)
checkout([
$class: 'GitSCM',
userRemoteConfigs: [