From b18dba3c00b34ce1202609d5947050950679d98b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 13 May 2019 21:51:31 +0100 Subject: [PATCH 01/14] Print out items in sparse item list if the list is not empty --- versioncontrol/git.groovy | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index b639c91..fc15f81 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -93,6 +93,12 @@ def checkgitlfsinstall() { def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { checkgitlfsinstall() def reporootpath = checkouttoreporoot(gitURL) + if (!sparseitemlist.isEmpty()) { + echo "Items in sparse item list: " + for (item in sparseitemlist) { + echo item + } + } checkout([ $class: 'GitSCM', userRemoteConfigs: [ From 4c4958db9b40be65fa611df7a5feb3e820873483 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 13 May 2019 22:11:54 +0100 Subject: [PATCH 02/14] Print out items in sparse item list if the list is not empty --- versioncontrol/git.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index fc15f81..56d206c 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -94,10 +94,11 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo checkgitlfsinstall() def reporootpath = checkouttoreporoot(gitURL) if (!sparseitemlist.isEmpty()) { - echo "Items in sparse item list: " + def itemstring = "Items in sparse item list:\n" for (item in sparseitemlist) { - echo item + itemstring += item + "\n" } + echo itemstring } checkout([ $class: 'GitSCM', @@ -114,7 +115,7 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo [$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120], [$class: 'CheckoutOption', timeout: 120], [$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir], - sparsecheckoutconfig(sparseitemlist) + [$class: 'SparseCheckoutPaths', sparseCheckoutPaths: sparsecheckoutconfig(sparseitemlist)], ], submoduleCfg: [], ]) From 5be5dfce45b25b7544fc9b0012f51905c66581d1 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 13 May 2019 22:14:22 +0100 Subject: [PATCH 03/14] Print out items in sparse item list if the list is not empty --- versioncontrol/git.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 56d206c..5a92884 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -115,7 +115,7 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo [$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120], [$class: 'CheckoutOption', timeout: 120], [$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir], - [$class: 'SparseCheckoutPaths', sparseCheckoutPaths: sparsecheckoutconfig(sparseitemlist)], + [$class: 'SparseCheckoutPaths', sparsecheckoutconfig(sparseitemlist)], ], submoduleCfg: [], ]) From ddc231ccacd21a672eaf1be65fa30640ba692178 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 13 May 2019 22:54:47 +0100 Subject: [PATCH 04/14] Print out items in sparse item list if the list is not empty --- versioncontrol/git.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 5a92884..b37bbc7 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -11,12 +11,12 @@ String getGitInfo(String workingSetRootPath) { } @NonCPS -def SparseCheckoutPaths sparsecheckoutconfig(ArrayList paths) { +def ArrayList sparsecheckoutconfig(ArrayList paths) { ArrayList sparsecheckoutpaths = new ArrayList() for (path in paths) { sparsecheckoutpaths.add(new SparseCheckoutPath(path)) } - return new SparseCheckoutPaths(sparsecheckoutpaths) + return sparsecheckoutpaths } def String uniquereporootname(String gitURL) { @@ -115,7 +115,7 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo [$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120], [$class: 'CheckoutOption', timeout: 120], [$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir], - [$class: 'SparseCheckoutPaths', sparsecheckoutconfig(sparseitemlist)], + [$class: 'SparseCheckoutPaths', sparseCheckoutPaths: sparsecheckoutconfig(sparseitemlist)], ], submoduleCfg: [], ]) From 2c9113cc4d8045de29f6a9aeb33f9c5501904aab Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 13 May 2019 23:17:20 +0100 Subject: [PATCH 05/14] Print out items in sparse item list if the list is not empty --- publish/publish.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/publish/publish.groovy b/publish/publish.groovy index b478a5d..b74b72a 100644 --- a/publish/publish.groovy +++ b/publish/publish.groovy @@ -32,6 +32,15 @@ pipeline { } } } + stage('Test sparse checkout') { + steps { + script { + def gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy") + def ArrayList publishablepaths = ['installers/KM/'] + gh.gitCheckout('git@hydra:releases/print-server-installer.git', 'origin/master', 'testfolder', "", 1, true, publishablepaths) // Shallow clone + } + } + } stage('Get release artifact meta') { steps { script { From 7b50a27c26a0b492ddd17160babbaaa40756ef2d Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 13 May 2019 23:23:32 +0100 Subject: [PATCH 06/14] Print out items in sparse item list if the list is not empty --- publish/publish.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publish/publish.groovy b/publish/publish.groovy index b74b72a..6f9fd44 100644 --- a/publish/publish.groovy +++ b/publish/publish.groovy @@ -36,7 +36,7 @@ pipeline { steps { script { def gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy") - def ArrayList publishablepaths = ['installers/KM/'] + def ArrayList publishablepaths = ['installers/KM/*'] gh.gitCheckout('git@hydra:releases/print-server-installer.git', 'origin/master', 'testfolder', "", 1, true, publishablepaths) // Shallow clone } } From 6b9f624770a3e093ffdde027ed228d9d0880b9d0 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 14 May 2019 09:11:38 +0100 Subject: [PATCH 07/14] Need an alternative way to checkout because git plugin is not working when using LFS and sparse checkout simultaneously --- versioncontrol/git.groovy | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index b37bbc7..fed039a 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -90,6 +90,91 @@ def checkgitlfsinstall() { } } +def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { + checkgitlfsinstall() + def reporootpath = checkouttoreporoot(gitURL) + if (!sparseitemlist.isEmpty()) { + def itemstring = "Items in sparse item list:\n" + for (item in sparseitemlist) { + itemstring += item + "\n" + } + echo itemstring + } + 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], + [$class: 'SparseCheckoutPaths', sparseCheckoutPaths: sparsecheckoutconfig(sparseitemlist)], + ], + submoduleCfg: [], + ]) +} + +//No credentials specified +//Cloning the remote Git repository +//Cloning repository git@hydra:print-server-releases/print_server_whole.git +//> git init /home/jenkins_user/jenkins/jobs/Print_Server_publish_to_customer/ws/whole # timeout=10 +//Using reference repository: /home/jenkins_user/reporoot/git_hydra_print_server_releases_print_server_whole_git +//Fetching upstream changes from git@hydra:print-server-releases/print_server_whole.git +// > git --version # timeout=10 +// > git fetch --tags --progress git@hydra:print-server-releases/print_server_whole.git +refs/heads/*:refs/remotes/origin/* # timeout=120 +// > git config remote.origin.url git@hydra:print-server-releases/print_server_whole.git # timeout=10 +// > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 +// > git config remote.origin.url git@hydra:print-server-releases/print_server_whole.git # timeout=10 +// Cleaning workspace +// > git rev-parse --verify HEAD # timeout=10 +// No valid HEAD. Skipping the resetting +// > git clean -fdx # timeout=10 +// Fetching upstream changes from git@hydra:print-server-releases/print_server_whole.git +// > git fetch --tags --progress git@hydra:print-server-releases/print_server_whole.git +refs/heads/*:refs/remotes/origin/* # timeout=120 +// > git rev-parse refs/tags/2.10180.7389.21125_7^{commit} # timeout=10 +// > git rev-parse refs/remotes/origin/refs/tags/2.10180.7389.21125_7^{commit} # timeout=10 +// Checking out Revision 64cac35e9a7603c060135f61f91b3f809bbdf160 (refs/tags/2.10180.7389.21125_7) +// Enabling Git LFS pull +// > git config core.sparsecheckout # timeout=10 +// > git checkout -f 64cac35e9a7603c060135f61f91b3f809bbdf160 # timeout=120 +// > git config --get remote.origin.url # timeout=10 +// > git lfs pull origin # timeout=120 +// Commit message: "2.10180.7389.21125_7" +// > git rev-list --no-walk 64cac35e9a7603c060135f61f91b3f809bbdf160 # timeout=10 + + +// > git rev-parse --is-inside-work-tree # timeout=10 +// Fetching changes from the remote Git repository +// > git config remote.origin.url git@hydra:releases/print-server-installer.git # timeout=10 +// Cleaning workspace +// > git rev-parse --verify HEAD # timeout=10 +// Resetting working tree +// > git reset --hard # timeout=10 +// > git clean -fdx # timeout=10 +// Using shallow fetch with depth 1 +// Fetching upstream changes from git@hydra:releases/print-server-installer.git +// > git --version # timeout=10 +// > git fetch --tags --progress git@hydra:releases/print-server-installer.git +refs/heads/*:refs/remotes/origin/* --depth=1 # timeout=120 +// > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 +// > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 +// Checking out Revision d0788d22622862e441c5995a22629846573c39f3 (refs/remotes/origin/master) +// Enabling Git LFS pull +// > git config core.sparsecheckout # timeout=10 +// > git read-tree -mu HEAD # timeout=10 +// > git checkout -f d0788d22622862e441c5995a22629846573c39f3 # timeout=120 +// > git config --get remote.origin.url # timeout=10 +// > git lfs pull origin # timeout=120 +// Commit message: "2.10180.7389.21125_3" +// > git rev-list --no-walk d0788d22622862e441c5995a22629846573c39f3 # timeout=10 + +// gitCheckout (below) cannot handle sparse checkout and lfs at the moment - see https://issues.jenkins-ci.org/browse/JENKINS-43427 - see gitCheckoutAlt() def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { checkgitlfsinstall() def reporootpath = checkouttoreporoot(gitURL) From a6cdcccb123d651b62c93fcc1792c4aaa955fe7b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 14 May 2019 23:21:35 +0100 Subject: [PATCH 08/14] Try to get sparse checkout to work with lfs --- publish/do.groovy | 2 +- versioncontrol/git.groovy | 96 +++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 35 deletions(-) diff --git a/publish/do.groovy b/publish/do.groovy index b63b15c..1599ca8 100644 --- a/publish/do.groovy +++ b/publish/do.groovy @@ -83,7 +83,7 @@ def getcomponentartifacts(releaseinfo, String repofolder, String tempfolder, ite } if (publishablepaths.size() > 0) { def reporootsuffix = guessreporootsuffix(componentURL) - gh.gitCheckout(componentURL, revision, repofolder, reporootsuffix, 1, true, publishablepaths) // Shallow clone + gh.gitCheckoutAlt(componentURL, revision, repofolder, reporootsuffix, 1, true, publishablepaths) // Shallow clone } else { summaryappend("None ") diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index fed039a..1652e6b 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -90,37 +90,6 @@ def checkgitlfsinstall() { } } -def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { - checkgitlfsinstall() - def reporootpath = checkouttoreporoot(gitURL) - if (!sparseitemlist.isEmpty()) { - def itemstring = "Items in sparse item list:\n" - for (item in sparseitemlist) { - itemstring += item + "\n" - } - echo itemstring - } - 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], - [$class: 'SparseCheckoutPaths', sparseCheckoutPaths: sparsecheckoutconfig(sparseitemlist)], - ], - submoduleCfg: [], - ]) -} - //No credentials specified //Cloning the remote Git repository //Cloning repository git@hydra:print-server-releases/print_server_whole.git @@ -174,10 +143,12 @@ def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repo // Commit message: "2.10180.7389.21125_3" // > git rev-list --no-walk d0788d22622862e441c5995a22629846573c39f3 # timeout=10 -// gitCheckout (below) cannot handle sparse checkout and lfs at the moment - see https://issues.jenkins-ci.org/browse/JENKINS-43427 - see gitCheckoutAlt() -def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { +def String lfsinstallandreporoot(String gitURL) { checkgitlfsinstall() - def reporootpath = checkouttoreporoot(gitURL) + return checkouttoreporoot(gitURL) +} + +def showsparseitemlist(ArrayList sparseitemlist = new ArrayList()) { if (!sparseitemlist.isEmpty()) { def itemstring = "Items in sparse item list:\n" for (item in sparseitemlist) { @@ -185,6 +156,9 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo } echo itemstring } +} + +def docheckout(String gitURL, String revision, int cloneDepth, String reporootpath, boolean shallowClone, String targetDir, sparseitemlist) { checkout([ $class: 'GitSCM', userRemoteConfigs: [ @@ -206,6 +180,60 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo ]) } +// gitCheckout (below) cannot handle sparse checkout and lfs at the moment - see https://issues.jenkins-ci.org/browse/JENKINS-43427 - see gitCheckoutAlt() +def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { + def String reporootpath = lfsinstallandreporoot(gitURL) + showsparseitemlist(sparseitemlist) + docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist) +} + +def gitinit(String targetDir, String reporootpath) { + if (!fileExists("${targetDir}/.git")) { // Git folder does not already exist + if (isUnix()) { + sh """ + git init "${targetDir}" + """ + } else { + bat """ + git init "${targetDir}" + """ + } + dir("${targetDir}/.git/objects/info") { + writeFile(file: 'alternates', text: "${reporootpath}/.git/objects") + } + } +} + +def setlfsfetchinclude(String targetDir, ArrayList sparseitemlist) { + def String sparseitemliststring = "" + if (!sparseitemlist.isEmpty()) { + for (item in sparseitemlist) { + sparseitemliststring += "${item}," + } + dir(targetDir) { + if (isUnix()) { + sh """ + git config lfs.fetchinclude "${sparseitemliststring}" + """ + } else { + bat """ + git config lfs.fetchinclude "${sparseitemliststring}" + """ + } + } + } +} + +def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { + def String reporootpath = lfsinstallandreporoot(gitURL) + showsparseitemlist(sparseitemlist) + if (!sparseitemlist.isEmpty()) { + gitinit(targetDir, reporootpath) + setlfsfetchinclude(targetDir, sparseitemlist) + } + docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist) +} + def checkRepoExists(String gitURL) { def int result = 0 if (isUnix()) { From 3686e219763bdaaf9608366e0bc57bfc5e63c4f1 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 14 May 2019 23:32:18 +0100 Subject: [PATCH 09/14] Try to get sparse checkout to work with lfs --- versioncontrol/git.groovy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 1652e6b..a5890f2 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -189,6 +189,7 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo def gitinit(String targetDir, String reporootpath) { if (!fileExists("${targetDir}/.git")) { // Git folder does not already exist + echo "git init ${targetDir}" if (isUnix()) { sh """ git init "${targetDir}" @@ -198,6 +199,7 @@ def gitinit(String targetDir, String reporootpath) { git init "${targetDir}" """ } + echo "Writing ${reporootpath}/.git/objects to ${targetDir}/.git/objects/info/alternates" dir("${targetDir}/.git/objects/info") { writeFile(file: 'alternates', text: "${reporootpath}/.git/objects") } @@ -210,6 +212,7 @@ def setlfsfetchinclude(String targetDir, ArrayList sparseitemlist) { for (item in sparseitemlist) { sparseitemliststring += "${item}," } + echo "git config lfs.fetchinclude ${sparseitemliststring}" dir(targetDir) { if (isUnix()) { sh """ @@ -225,6 +228,7 @@ def setlfsfetchinclude(String targetDir, ArrayList sparseitemlist) { } def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { + echo "Performing alternative checkout" def String reporootpath = lfsinstallandreporoot(gitURL) showsparseitemlist(sparseitemlist) if (!sparseitemlist.isEmpty()) { From f29e1beb7b0774d09dbc87d8d5810b3e8ae65bc5 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 14 May 2019 23:34:52 +0100 Subject: [PATCH 10/14] Try to get sparse checkout to work with lfs --- publish/publish.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publish/publish.groovy b/publish/publish.groovy index 6f9fd44..e4539f1 100644 --- a/publish/publish.groovy +++ b/publish/publish.groovy @@ -37,7 +37,7 @@ pipeline { script { def gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy") def ArrayList publishablepaths = ['installers/KM/*'] - gh.gitCheckout('git@hydra:releases/print-server-installer.git', 'origin/master', 'testfolder', "", 1, true, publishablepaths) // Shallow clone + gh.gitCheckoutAlt('git@hydra:releases/print-server-installer.git', 'origin/master', 'testfolder', "", 1, true, publishablepaths) // Shallow clone } } } From 1aee93e12163bc61a6dbacadf895674519b2fae0 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 14 May 2019 23:42:49 +0100 Subject: [PATCH 11/14] Try to get sparse checkout to work with lfs --- versioncontrol/git.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index a5890f2..1bf9cd1 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -199,10 +199,10 @@ def gitinit(String targetDir, String reporootpath) { git init "${targetDir}" """ } - echo "Writing ${reporootpath}/.git/objects to ${targetDir}/.git/objects/info/alternates" - dir("${targetDir}/.git/objects/info") { - writeFile(file: 'alternates', text: "${reporootpath}/.git/objects") - } + } + echo "Writing ${reporootpath}/.git/objects to ${targetDir}/.git/objects/info/alternates" + dir("${targetDir}/.git/objects/info") { + writeFile(file: 'alternates', text: "${reporootpath}/.git/objects") } } From eb8a1005ec7f2e4f62e65a76f9386d72e3514699 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Wed, 15 May 2019 00:02:48 +0100 Subject: [PATCH 12/14] Try to get sparse checkout to work with lfs --- versioncontrol/git.groovy | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index 1bf9cd1..ccbd458 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -227,6 +227,25 @@ def setlfsfetchinclude(String targetDir, ArrayList sparseitemlist) { } } +def gitsparserestore(String targetDir) { + echo "Clean out full fetch; Force a sparse fetch" + dir(targetDir) { + if (isUnix()) { + sh """ + git rm -rf . + git clean -fxd + git reset --hard + """ + } else { + bat """ + git rm -rf . + git clean -fxd + git reset --hard + """ + } + } + } + def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList sparseitemlist = new ArrayList()) { echo "Performing alternative checkout" def String reporootpath = lfsinstallandreporoot(gitURL) @@ -236,6 +255,9 @@ def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repo setlfsfetchinclude(targetDir, sparseitemlist) } docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist) + if (!sparseitemlist.isEmpty()) { + gitsparserestore(targetDir) + } } def checkRepoExists(String gitURL) { From 35ef539f5c85632660016fcbd60a58179001894b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Wed, 15 May 2019 00:16:04 +0100 Subject: [PATCH 13/14] Try to get sparse checkout to work with lfs --- versioncontrol/git.groovy | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/versioncontrol/git.groovy b/versioncontrol/git.groovy index ccbd458..8886076 100644 --- a/versioncontrol/git.groovy +++ b/versioncontrol/git.groovy @@ -232,15 +232,15 @@ def gitsparserestore(String targetDir) { dir(targetDir) { if (isUnix()) { sh """ - git rm -rf . - git clean -fxd - git reset --hard + git rm -rf . > /dev/null + git clean -fxd > /dev/null + git reset --hard > /dev/null """ } else { bat """ - git rm -rf . - git clean -fxd - git reset --hard + git rm -rf . 2> nul + git clean -fxd 2> nul + git reset --hard 2> nul """ } } From c1ceeca1430b9d90f792572c38291bbc7ea60aab Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Wed, 15 May 2019 00:22:01 +0100 Subject: [PATCH 14/14] Try to get sparse checkout to work with lfs --- publish/publish.groovy | 9 --------- 1 file changed, 9 deletions(-) diff --git a/publish/publish.groovy b/publish/publish.groovy index e4539f1..b478a5d 100644 --- a/publish/publish.groovy +++ b/publish/publish.groovy @@ -32,15 +32,6 @@ pipeline { } } } - stage('Test sparse checkout') { - steps { - script { - def gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy") - def ArrayList publishablepaths = ['installers/KM/*'] - gh.gitCheckoutAlt('git@hydra:releases/print-server-installer.git', 'origin/master', 'testfolder', "", 1, true, publishablepaths) // Shallow clone - } - } - } stage('Get release artifact meta') { steps { script {