Merge commit 'b380eef774' into 1.10003.j20-comscr
This commit is contained in:
parent
b380eef774
commit
10e2a57178
1 changed files with 0 additions and 135 deletions
|
|
@ -1,135 +0,0 @@
|
|||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
summaryfolder = "${WORKSPACE}/summary"
|
||||
summaryfile = "${summaryfolder}/summary.txt"
|
||||
releaserepofolder = "${WORKSPACE}/releaserepos"
|
||||
tempfolder = "${WORKSPACE}/temp"
|
||||
|
||||
def resetfolders() {
|
||||
dir(summaryfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(releaserepofolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(tempfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
def preconditions() {
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
writeFile(file: summaryfile, text: "Release 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)
|
||||
}
|
||||
|
||||
def checkoutreleaserepo(info, String checkoutfolder) {
|
||||
def String releaserepo = info.meta.releaseinfo.releaserepoURL
|
||||
// Get the latest head revision of the release repo without checking out working copy; Check out to a folder unique to component
|
||||
dir(releaserepofolder) {
|
||||
sh("git clone -n --depth 1 ${releaserepo} ${checkoutfolder}")
|
||||
}
|
||||
}
|
||||
|
||||
def getcomponentartifacts(info, String repofolder, String tempfolder) {
|
||||
// Copy relevant artifacts to temp folder
|
||||
summaryappend("Artifacts: ")
|
||||
for (artifactfilter in info.meta.releaseinfo.releaseitems) {
|
||||
def filterpath = artifactfilter
|
||||
if (info.offsetpath) {
|
||||
filterpath = info.offsetpath + '/' + artifactfilter
|
||||
}
|
||||
// Copy relevant artifacts to temp folder
|
||||
echo "Copying artifacts: ${filterpath} to ${tempfolder}"
|
||||
copyArtifacts(
|
||||
filter: filterpath,
|
||||
projectName: BUILD_JOB,
|
||||
selector: [
|
||||
$class: 'ParameterizedBuildSelector',
|
||||
parameterName: BUILD_JOB_SELECTOR
|
||||
],
|
||||
target: tempfolder
|
||||
)
|
||||
// Move relevant artifacts from temp folder to release position
|
||||
def originalrootdir = tempfolder + "/" + info.offsetpath
|
||||
dir(originalrootdir) {
|
||||
sh("mv * ${repofolder}")
|
||||
}
|
||||
summaryappend("${artifactfilter},")
|
||||
}
|
||||
}
|
||||
|
||||
def gitrelease(String releaserepo, String buildstamp, String dryrunpush) {
|
||||
summaryappend(" Git operations: ")
|
||||
dir(releaserepo) {
|
||||
// Add anything new
|
||||
sh("git add .")
|
||||
summaryappend("Add,")
|
||||
// Perform git commit (if necessary)
|
||||
def changesoccurred = sh(script: "git status --porcelain", returnStdout: true)
|
||||
if (changesoccurred) {
|
||||
sh("git commit -a -m ${buildstamp}")
|
||||
summaryappend("Commit,")
|
||||
}
|
||||
else {
|
||||
summaryappend("No-commit,")
|
||||
}
|
||||
// Tag with buildstamp
|
||||
sh("git tag ${buildstamp}")
|
||||
summaryappend("Tag (${buildstamp}),")
|
||||
if (dryrunpush == "true") {
|
||||
sh("git push -n --tags origin master")
|
||||
summaryappend("Dry-Run-Push,")
|
||||
setunstable("The artifact(s) have not been pushed/saved (\"Dry run push\" parameter/option is selected)")
|
||||
}
|
||||
else {
|
||||
sh("git push --tags origin master")
|
||||
summaryappend("Push")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def releasecomponent(info, String dryrunpush) {
|
||||
def String uniquefolder = "${info.meta.productinfo.productname}_${info.meta.productinfo.subcomponentname}"
|
||||
def String uniquefolderforrepo = "${releaserepofolder}/${uniquefolder}"
|
||||
def String uniquefoldertemp = "${tempfolder}/${uniquefolder}"
|
||||
|
||||
summaryappend("${info.meta.productinfo.productname} ${info.meta.productinfo.subcomponentname}: ")
|
||||
checkoutreleaserepo(info, uniquefolderforrepo)
|
||||
|
||||
getcomponentartifacts(info, uniquefolderforrepo, uniquefoldertemp)
|
||||
|
||||
def String buildstamp = info.meta.buildstampinfo.buildstamp
|
||||
gitrelease(uniquefolderforrepo, buildstamp, dryrunpush)
|
||||
|
||||
summaryappend("\n")
|
||||
}
|
||||
|
||||
def releasehierarchy(buildmeta, String maxdepth, dryrunpush) {
|
||||
int md = maxdepth.toInteger()
|
||||
resetfolders()
|
||||
preconditions()
|
||||
|
||||
// Walk the meta information to a max depth, looking for artifacts to import for release
|
||||
componentReleaseInfo = buildmeta.releasewalkerunique(md)
|
||||
|
||||
// For each component
|
||||
for (key in componentReleaseInfo.keySet()) {
|
||||
def info = componentReleaseInfo[key]
|
||||
releasecomponent(info, dryrunpush)
|
||||
}
|
||||
return [markunstable, unstablereason]
|
||||
}
|
||||
|
||||
return this;
|
||||
Loading…
Add table
Add a link
Reference in a new issue