Merge commit 'c1ceeca143'
This commit is contained in:
commit
a51e974845
2 changed files with 152 additions and 6 deletions
|
|
@ -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 ")
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ String getGitInfo(String workingSetRootPath) {
|
|||
}
|
||||
|
||||
@NonCPS
|
||||
def SparseCheckoutPaths sparsecheckoutconfig(ArrayList<String> paths) {
|
||||
def ArrayList<SparseCheckoutPath> sparsecheckoutconfig(ArrayList<String> paths) {
|
||||
ArrayList<SparseCheckoutPath> sparsecheckoutpaths = new ArrayList<SparseCheckoutPath>()
|
||||
for (path in paths) {
|
||||
sparsecheckoutpaths.add(new SparseCheckoutPath(path))
|
||||
}
|
||||
return new SparseCheckoutPaths(sparsecheckoutpaths)
|
||||
return sparsecheckoutpaths
|
||||
}
|
||||
|
||||
def String uniquereporootname(String gitURL) {
|
||||
|
|
@ -90,9 +90,75 @@ def checkgitlfsinstall() {
|
|||
}
|
||||
}
|
||||
|
||||
def gitCheckout(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
||||
//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
|
||||
|
||||
def String lfsinstallandreporoot(String gitURL) {
|
||||
checkgitlfsinstall()
|
||||
def reporootpath = checkouttoreporoot(gitURL)
|
||||
return checkouttoreporoot(gitURL)
|
||||
}
|
||||
|
||||
def showsparseitemlist(ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
def itemstring = "Items in sparse item list:\n"
|
||||
for (item in sparseitemlist) {
|
||||
itemstring += item + "\n"
|
||||
}
|
||||
echo itemstring
|
||||
}
|
||||
}
|
||||
|
||||
def docheckout(String gitURL, String revision, int cloneDepth, String reporootpath, boolean shallowClone, String targetDir, sparseitemlist) {
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
userRemoteConfigs: [
|
||||
|
|
@ -108,12 +174,92 @@ 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: [],
|
||||
])
|
||||
}
|
||||
|
||||
// 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<String> sparseitemlist = new ArrayList<String>()) {
|
||||
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
|
||||
echo "git init ${targetDir}"
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git init "${targetDir}"
|
||||
"""
|
||||
} else {
|
||||
bat """
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
def setlfsfetchinclude(String targetDir, ArrayList<String> sparseitemlist) {
|
||||
def String sparseitemliststring = ""
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
for (item in sparseitemlist) {
|
||||
sparseitemliststring += "${item},"
|
||||
}
|
||||
echo "git config lfs.fetchinclude ${sparseitemliststring}"
|
||||
dir(targetDir) {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git config lfs.fetchinclude "${sparseitemliststring}"
|
||||
"""
|
||||
} else {
|
||||
bat """
|
||||
git config lfs.fetchinclude "${sparseitemliststring}"
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def gitsparserestore(String targetDir) {
|
||||
echo "Clean out full fetch; Force a sparse fetch"
|
||||
dir(targetDir) {
|
||||
if (isUnix()) {
|
||||
sh """
|
||||
git rm -rf . > /dev/null
|
||||
git clean -fxd > /dev/null
|
||||
git reset --hard > /dev/null
|
||||
"""
|
||||
} else {
|
||||
bat """
|
||||
git rm -rf . 2> nul
|
||||
git clean -fxd 2> nul
|
||||
git reset --hard 2> nul
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
||||
echo "Performing alternative checkout"
|
||||
def String reporootpath = lfsinstallandreporoot(gitURL)
|
||||
showsparseitemlist(sparseitemlist)
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
gitinit(targetDir, reporootpath)
|
||||
setlfsfetchinclude(targetDir, sparseitemlist)
|
||||
}
|
||||
docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist)
|
||||
if (!sparseitemlist.isEmpty()) {
|
||||
gitsparserestore(targetDir)
|
||||
}
|
||||
}
|
||||
|
||||
def checkRepoExists(String gitURL) {
|
||||
def int result = 0
|
||||
if (isUnix()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue