Merge commit 'add368c009' into production
This commit is contained in:
commit
d5608d9d99
1 changed files with 41 additions and 15 deletions
|
|
@ -19,25 +19,51 @@ def SparseCheckoutPaths sparsecheckoutconfig(ArrayList<String> paths) {
|
|||
return new SparseCheckoutPaths(sparsecheckoutpaths)
|
||||
}
|
||||
|
||||
def guessreporoot(componentURL) {
|
||||
if (!env.REPO_ROOT || env.REPO_ROOT.size() == 0) {
|
||||
return ''
|
||||
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)
|
||||
reporootsubfolder = "${reporootenv}/${reporootname}"
|
||||
|
||||
if (!fileExists(reporootsubfolder)) {
|
||||
echo "Checking out ${gitURL} to ${reporootsubfolder}"
|
||||
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 ${reporootsubfolder}"
|
||||
}
|
||||
}
|
||||
def guess = componentURL.replaceFirst(/.*\/(.*).git/, '$1')
|
||||
def reporoot = "${REPO_ROOT}/${guess}"
|
||||
echo "Guessing reporoot is: ${reporoot}"
|
||||
return reporoot
|
||||
return reporootsubfolder
|
||||
}
|
||||
|
||||
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 = ""
|
||||
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"
|
||||
}
|
||||
def reporootpath = checkouttoreporoot(gitURL)
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
userRemoteConfigs: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue