Merge commit 'e3bf9774ed'
This commit is contained in:
commit
c29ba02438
5 changed files with 150 additions and 10 deletions
|
|
@ -4,7 +4,6 @@ def combineSubjobArtifacts(meta, subJobs) {
|
|||
def importer = load("${autobuilder.commonscripts()}/import/importer.groovy")
|
||||
|
||||
def ArrayList<String> artifactFolders = new ArrayList<String>()
|
||||
int revisiontotal = 0
|
||||
for (subJob in subJobs) {
|
||||
def subJobObject = subJob[0]
|
||||
if (subJobObject != null) {
|
||||
|
|
@ -14,14 +13,11 @@ def combineSubjobArtifacts(meta, subJobs) {
|
|||
dir(destFolder) {
|
||||
deleteDir()
|
||||
}
|
||||
importedmeta = importer.artifactimport(meta, subJobName, subJobNumber, destFolder)
|
||||
revisiontotal += importedmeta.buildstampinfo.revision
|
||||
importer.artifactimport(meta, subJobName, subJobNumber, destFolder)
|
||||
artifactFolders.add("${destFolder}/**")
|
||||
}
|
||||
}
|
||||
def versiongenerator = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy")
|
||||
revisiontotal = revisiontotal % (versiongenerator.maxversionnumber() + 1)
|
||||
return [artifactFolders, revisiontotal]
|
||||
return artifactFolders
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
versiongenerator = load("${autobuilder.commonscripts()}/versionnumbering/generate.groovy")
|
||||
|
||||
def artifactimport(meta, String jenkinsjob, int buildnumber, String destpath, String filter = '**', String excludes = '', boolean fingerprint = false) {
|
||||
copyArtifacts(
|
||||
|
|
@ -8,7 +9,9 @@ def artifactimport(meta, String jenkinsjob, int buildnumber, String destpath, St
|
|||
selector: specific(buildnumber.toString()),
|
||||
target: destpath
|
||||
)
|
||||
return meta.importrelated(destpath)
|
||||
def importedmeta = meta.importrelated(destpath)
|
||||
meta.buildstampinfo.changerevision(versiongenerator.incrementrevision(meta.buildstampinfo.revision, importedmeta.buildstampinfo.revision))
|
||||
return importedmeta
|
||||
}
|
||||
|
||||
def artifactimport(meta, String jenkinsjob, String buildselector, String destpath, String filter = '**', String excludes = '', boolean fingerprint = false) {
|
||||
|
|
@ -23,7 +26,9 @@ def artifactimport(meta, String jenkinsjob, String buildselector, String destpat
|
|||
],
|
||||
target: destpath
|
||||
)
|
||||
return meta.importrelated(destpath)
|
||||
def importedmeta = meta.importrelated(destpath)
|
||||
meta.buildstampinfo.changerevision(versiongenerator.incrementrevision(meta.buildstampinfo.revision, importedmeta.buildstampinfo.revision))
|
||||
return importedmeta
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
|||
119
publish/do.groovy
Normal file
119
publish/do.groovy
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
summaryfolder = "${WORKSPACE}/summary"
|
||||
summaryfile = "${summaryfolder}/summary.txt"
|
||||
summarystring = ""
|
||||
releaserepofolder = "${WORKSPACE}/releaserepos"
|
||||
tempfolder = "${WORKSPACE}/temp"
|
||||
|
||||
def resetfolders() {
|
||||
dir(summaryfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(releaserepofolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(tempfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
def preconditions() {
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
summarystring = ""
|
||||
writeFile(file: summaryfile, text: "Publish summary: \n")
|
||||
}
|
||||
|
||||
def setunstable(String reason) {
|
||||
markunstable = true
|
||||
unstablereason = reason
|
||||
}
|
||||
|
||||
def summaryappend(String summary) {
|
||||
def String currentsummarycontents = readFile(file: summaryfile)
|
||||
writeFile(file: summaryfile, text: currentsummarycontents + summary)
|
||||
summarystring += summary
|
||||
}
|
||||
|
||||
gh = load("${autobuilder.commonscripts()}/versioncontrol/git.groovy")
|
||||
def getcomponentartifacts(releaseinfo, String repofolder, String tempfolder) {
|
||||
// Copy relevant artifacts to temp folder
|
||||
summaryappend("Artifacts: ")
|
||||
|
||||
def releasemeta = releaseinfo.meta
|
||||
def String componentURL = releasemeta.releaseinfo.releaserepoURL
|
||||
def String revision = "refs/tags/${releasemeta.buildstampinfo.buildstamp}"
|
||||
def publishableitems = releasemeta.publishableinfo
|
||||
def ArrayList<String> publishablePaths = new ArrayList<String>()
|
||||
if (publishableitems.size() > 0) {
|
||||
for (publishableitem in publishableitems) {
|
||||
publishablePaths.add(publishableitem.filepath)
|
||||
summaryappend("${publishableitem.filepath},")
|
||||
}
|
||||
gh.gitCheckout(componentURL, revision, repofolder, "", 1, true, publishablePaths) // Shallow clone
|
||||
}
|
||||
else {
|
||||
summaryappend("None ")
|
||||
}
|
||||
}
|
||||
|
||||
def publish(String customer) {
|
||||
summaryappend(" FTP operations: ")
|
||||
|
||||
def String FTP_CLIENT_LOCATION='ftp'
|
||||
def String FTP_URL='ie1.hostedftp.com'
|
||||
def String FTP_USER='ftp@globalinkjetsystems.com'
|
||||
def String FTP_CUSTOMER_ROOT="/Customers/${customer}"
|
||||
def String FTP_PASSWORD='ramshorn42'
|
||||
dir(releaserepofolder) {
|
||||
summaryappend("FTP operations: Transferring to ${FTP_CUSTOMER_ROOT}")
|
||||
sh """#!/bin/bash
|
||||
ncftpput -u ${FTP_USER} -p ${FTP_PASSWORD} -R ${FTP_URL} "${FTP_CUSTOMER_ROOT}" .
|
||||
"""
|
||||
summaryappend(", Transferred ")
|
||||
}
|
||||
}
|
||||
|
||||
def recallcomponent(releaseinfo, String softwarerelease) {
|
||||
def releasemeta = releaseinfo.meta
|
||||
def String uniquefolder = "Software/${PRODUCT_NAME} ${software_release}/${releasemeta.productinfo.productname}_${releasemeta.productinfo.subcomponentname}"
|
||||
def String uniquefolderforrepo = "${releaserepofolder}/${uniquefolder}"
|
||||
def String uniquefoldertemp = "${tempfolder}/${uniquefolder}"
|
||||
|
||||
summaryappend("${releasemeta.productinfo.productname} ${releasemeta.productinfo.subcomponentname}: ")
|
||||
|
||||
getcomponentartifacts(releaseinfo, uniquefolderforrepo, uniquefoldertemp)
|
||||
|
||||
summaryappend("\n")
|
||||
}
|
||||
|
||||
def stripgithistory() {
|
||||
dir(releaserepofolder) {
|
||||
sh """#!/bin/bash
|
||||
( find . -type d -name ".git" && find . -name ".gitignore" && find . -name ".gitmodules" && find . -iname ".gitattributes") | xargs rm -rvf
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
def publishhierarchy(releasemeta, String customer, String softwarerelease, String maxdepth) {
|
||||
int md = maxdepth.toInteger()
|
||||
resetfolders()
|
||||
preconditions()
|
||||
|
||||
// Walk the meta information to a max depth, looking for artifacts to import for release
|
||||
componentReleaseInfo = releasemeta.releasewalkerunique(md)
|
||||
|
||||
// For each component
|
||||
for (key in componentReleaseInfo.keySet()) {
|
||||
def releaseinfo = componentReleaseInfo[key]
|
||||
recallcomponent(releaseinfo, softwarerelease)
|
||||
}
|
||||
stripgithistory()
|
||||
publish(customer)
|
||||
|
||||
return [summarystring, markunstable, unstablereason]
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
import hudson.plugins.git.*
|
||||
import hudson.plugins.git.extensions.*
|
||||
import hudson.plugins.git.extensions.impl.*
|
||||
|
||||
clh = load("${autobuilder.commonscripts()}/commandline/commandline.groovy")
|
||||
|
||||
String getGitInfo(String workingSetRootPath) {
|
||||
|
|
@ -6,7 +10,16 @@ String getGitInfo(String workingSetRootPath) {
|
|||
}
|
||||
}
|
||||
|
||||
def gitCheckout(String gitURL, String revision, String targetDir, String repoRoot = "", int cloneDepth = 1, boolean shallowClone = true) {
|
||||
@NonCPS
|
||||
def SparseCheckoutPaths sparsecheckoutconfig(ArrayList<String> paths) {
|
||||
ArrayList<SparseCheckoutPath> sparsecheckoutpaths = new ArrayList<SparseCheckoutPath>()
|
||||
for (path in paths) {
|
||||
sparsecheckoutpaths.add(new SparseCheckoutPath(path))
|
||||
}
|
||||
return new SparseCheckoutPaths(sparsecheckoutpaths)
|
||||
}
|
||||
|
||||
def gitCheckout(String gitURL, String revision, String targetDir, String repoRoot = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
|
||||
reporootenv = env.REPO_ROOT
|
||||
if (reporootenv != null && repoRoot != "") {
|
||||
reporootpath = "${reporootenv.trim()}/${repoRoot}"
|
||||
|
|
@ -28,7 +41,8 @@ def gitCheckout(String gitURL, String revision, String targetDir, String repoRoo
|
|||
[$class: 'CleanBeforeCheckout'],
|
||||
[$class: 'CloneOption', depth: cloneDepth, noTags: false, reference: reporootpath, shallow: shallowClone, timeout: 120],
|
||||
[$class: 'CheckoutOption', timeout: 120],
|
||||
[$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir]
|
||||
[$class: 'RelativeTargetDirectory', relativeTargetDir: targetDir],
|
||||
sparsecheckoutconfig(sparseitemlist)
|
||||
],
|
||||
submoduleCfg: [],
|
||||
])
|
||||
|
|
|
|||
|
|
@ -136,4 +136,10 @@ String generate(meta, String sourcerevision, String sourcepath, int basebuildnum
|
|||
return buildstamp
|
||||
}
|
||||
|
||||
int incrementrevision(int current, int increment) {
|
||||
def int newrevision = (current + increment) % (maxversionnumber() + 1)
|
||||
echo "Current revision: ${current} Increment: ${increment} New revision: ${newrevision}"
|
||||
return newrevision
|
||||
}
|
||||
|
||||
return this;
|
||||
Loading…
Add table
Add a link
Reference in a new issue