b70fe5fRemove debug release filtering3730461Debug release filteringdb92ee3Debug release filtering2393146Use releasetag script54bf29fAttempt to separate dependent products and sub-components3c4de23Debugging scriptd93f942Debugging scriptcaf71e3Debugging scriptc993eccDebugging script2e5b6b2Debugging script0ad763cDebugging scriptd5a178bDebugging script01d91a7Debugging scriptd2a22dbDebugging script30ac58dDebugging script490b37bDebugging script2939eafDebugging script35d3862Debugging scriptdefc807Debugging scriptf2e3e52Debugging scriptb5e2894Debugging scriptc2faf8aDebugging scriptfa199ebDebugging scriptd418e5aDebugging scriptf34fb2eDebugging script04e947cDebugging script48d7b0fDebugging script38b562bDebugging scriptac5e7cdDebugging script1d3f184Debugging scriptb187d23Debugging script1131865Debugging script68cbc00Debugging script5771490Debugginged17de0Debuggingb1bc540Debugginge6c6fcfDebugging57eeaf4Comment out code to debug latera576d64Script reorg32a3aedSupply release tag processing01ce780Supply release tag processingaf3e22dSupply release tag processingb7c5a66Supply release tag processing4fbe1d9Supply release tag processing44b1e13Supply release tag processingaf3c041Supply release tag processing8b361deSupply release tag processing89736f0Supply release tag processing70d569cSupply release tag processingd2b8d1bSupply release tag processingce33f59Supply release tag processing88cba3bSupply release tag processing80bc64eSupply release tag processing6488203Supply release tag processingc2b27a8Merge commit 'cd98f833a8db023604d045d9343f18f3a423da5c'704e499Start adding dependencies940a8d5Start adding dependencies4a46b8fBuild up a tag map0ca7886Build up a tag map3dbdf85Build up a tag mapfb72031Build up a tag mapbe599cbBuild up a tag map462b177Build up a tag map453a14aBuild up a tag mapc5f01d0Build up a tag map11826a4Get list of tags for each product release repo3981eceFilter long name releases from version selectioncad2d4eFilter long name releases from version selection8bd075fFilter long name releases from version selection20c5648Merge commit '6633e04d0257e6d52427b2ff761c8a5625196346' as 'Common_scripts'9a31bebRemove folder2767e8aRename foldera5ee31dNew files2c6a90dNew filese5d8c38Merge commit 'c1344e9084' as 'Commons_scripts'c1344e9Squashed 'Commons_scripts/' content from commit03268799171d4dInitial commite5bca0dInitial commit git-subtree-dir: Common_scripts git-subtree-split:b70fe5f7bd
400 lines
14 KiB
Groovy
400 lines
14 KiB
Groovy
import hudson.plugins.git.*
|
|
import hudson.plugins.git.extensions.*
|
|
import hudson.plugins.git.extensions.impl.*
|
|
|
|
clh = load("${autobuilder.commonscripts()}/commandline/commandline.groovy")
|
|
|
|
def boolean isShallowClonedRepo(String gitrootpath) {
|
|
def boolean isshallowclone = true
|
|
|
|
dir( gitrootpath) {
|
|
if (isUnix()) {
|
|
isshallowclone = sh(returnStdout: true, script: "git rev-parse --is-shallow-repository").trim().toBoolean()
|
|
}
|
|
else {
|
|
isshallowclone = powershell(returnStdout: true, script: "git rev-parse --is-shallow-repository").trim().toBoolean()
|
|
}
|
|
echo "Repo at ${gitrootpath} is shallow cloned: ${isshallowclone}"
|
|
}
|
|
return isshallowclone
|
|
}
|
|
|
|
String getGitInfo(String workingSetRootPath) {
|
|
dir(workingSetRootPath) {
|
|
return clh.getCommandOutput('git rev-parse HEAD')
|
|
}
|
|
}
|
|
|
|
ArrayList<String> gettaglist(String workingSetRootPath) {
|
|
ArrayList<String> taglist = new ArrayList<String>()
|
|
dir(workingSetRootPath) {
|
|
def tagliststring = clh.getCommandOutput('git tag --sort=-version:refname')
|
|
taglist = tagliststring.split('\\n')
|
|
}
|
|
return taglist
|
|
}
|
|
|
|
LinkedHashMap<String, ArrayList<String>> getremoteshatagmap(String repositoryURL) {
|
|
def shatagliststring = clh.getCommandOutput("git ls-remote --tags --sort=-version:refname ${repositoryURL}")
|
|
def shataglist = shatagliststring.split('\\n')
|
|
|
|
LinkedHashMap<String, ArrayList<String>> shatagmap = new LinkedHashMap<String, ArrayList<String>>()
|
|
for (shatag in shataglist) {
|
|
def shatagfields = shatag.split('\\t')
|
|
def sha = shatagfields[0].trim()
|
|
def tag = shatagfields[1].trim()
|
|
echo "sha: ${sha} tag: ${tag}"
|
|
if (shatagmap.get(sha) == null) {
|
|
def ArrayList<String> taglist = new ArrayList<String>()
|
|
taglist.add(tag)
|
|
shatagmap.put(sha, taglist)
|
|
} else {
|
|
def taglist = shatagmap.get(sha)
|
|
taglist.add(tag)
|
|
shatagmap.put(sha, taglist)
|
|
}
|
|
}
|
|
return shatagmap
|
|
}
|
|
|
|
@NonCPS
|
|
def ArrayList<SparseCheckoutPath> sparsecheckoutconfig(ArrayList<String> paths) {
|
|
ArrayList<SparseCheckoutPath> sparsecheckoutpaths = new ArrayList<SparseCheckoutPath>()
|
|
for (path in paths) {
|
|
sparsecheckoutpaths.add(new SparseCheckoutPath(path))
|
|
}
|
|
return sparsecheckoutpaths
|
|
}
|
|
|
|
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}"
|
|
/*
|
|
dir(reporootsubfolder) {
|
|
if (isUnix()) {
|
|
sh """
|
|
git status
|
|
if [ \$? -ne 0 ]; then exit 1; fi
|
|
"""
|
|
} else {
|
|
powershell """
|
|
git status
|
|
if (\$lastexitcode -ge 1) { exit 1 }
|
|
"""
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
return reporootsubfolder
|
|
}
|
|
|
|
def checkgitlfsinstall() {
|
|
if (isUnix()) {
|
|
sh """
|
|
git lfs install
|
|
if [ \$? -ne 0 ]; then exit 1; fi
|
|
"""
|
|
|
|
} else {
|
|
powershell """
|
|
git lfs install
|
|
if (\$lastexitcode -ge 1) { exit 1 }
|
|
"""
|
|
}
|
|
}
|
|
|
|
//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()
|
|
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) {
|
|
echo "Git: Checking out: URL: ${gitURL} Revision: ${revision} to: ${targetDir}"
|
|
checkout([
|
|
$class: 'GitSCM',
|
|
userRemoteConfigs: [
|
|
[url: gitURL]
|
|
],
|
|
branches: [
|
|
[name: revision]
|
|
],
|
|
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)],
|
|
[$class: 'PruneStaleBranch'],
|
|
],
|
|
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 {
|
|
powershell """
|
|
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 {
|
|
powershell """
|
|
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 {
|
|
powershell """
|
|
git rm -rf . > \$null
|
|
git clean -fxd > \$null
|
|
git reset --hard > \$null
|
|
"""
|
|
}
|
|
}
|
|
}
|
|
|
|
def List convertSparseItemsString(String itemstopublish) {
|
|
def List sparsepaths = []
|
|
|
|
boolean nonempty = itemstopublish?.trim()
|
|
if (nonempty) {
|
|
def String[] items = itemstopublish.trim().split(',')
|
|
def String allpaths = ""
|
|
for(String item : items) {
|
|
sparsepaths.add(item)
|
|
allpaths += "${item}\n"
|
|
}
|
|
echo "Selected item to publish:\n${allpaths}"
|
|
}
|
|
return sparsepaths
|
|
}
|
|
|
|
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()) {
|
|
result = sh( script: """
|
|
git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY
|
|
""",
|
|
returnStatus: true
|
|
)
|
|
} else {
|
|
result = powershell( script: """
|
|
git ls-remote "${gitURL}" CHECK_GIT_REMOTE_URL_REACHABILITY
|
|
""",
|
|
returnStatus: true
|
|
)
|
|
}
|
|
echo "git ls-remote return result: ${result}"
|
|
if (result > 0) {
|
|
error("The release repo: ${gitURL} cannot be found. Please ensure this exists before building")
|
|
} else {
|
|
echo "The release repo: ${gitURL} exists"
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
def stripgithistory(String rootfolder) {
|
|
echo "Stripping git history out of ${rootfolder}"
|
|
dir(rootfolder) {
|
|
if (isUnix()) {
|
|
sh """#!/bin/bash
|
|
pwd
|
|
find . -type d -name ".git" | xargs -iXX rm -rf XX
|
|
find . -name ".gitignore" | xargs -iXX rm -rf XX
|
|
find . -name ".gitmodules" | xargs -iXX rm -rf XX
|
|
find . -iname ".gitattributes" | xargs -iXX rm -rf XX
|
|
find . -iname "*@tmp" | xargs -iXX rm -rf XX
|
|
"""
|
|
} else {
|
|
echo "Not supporting git stripping in Windows at the moment"
|
|
}
|
|
}
|
|
}
|
|
|
|
return this
|