Add some checking job scripts
This commit is contained in:
parent
5cac7a574b
commit
d1741859bc
2 changed files with 150 additions and 0 deletions
86
check/build_meta.groovy
Normal file
86
check/build_meta.groovy
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
pipeline {
|
||||
agent { label "${AGENT_LABEL}" }
|
||||
stages {
|
||||
stage('Initial setup') {
|
||||
steps {
|
||||
script {
|
||||
autobuilderscript = load("${WORKSPACE}/autobuild/Common_scripts/autobuilder.groovy")
|
||||
meta = autobuilderscript.startnonbuild(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Clean exports') {
|
||||
steps {
|
||||
script {
|
||||
cleanfolders = [
|
||||
"${WORKSPACE}/build_artifacts",
|
||||
]
|
||||
cleaner = load("${autobuilder.commonscripts()}/clean/clean.groovy")
|
||||
cleaner.clean(cleanfolders)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Get build artifact meta') {
|
||||
steps {
|
||||
script {
|
||||
BUILD_ARTIFACTS = "${WORKSPACE}/build_artifacts"
|
||||
copyArtifacts(
|
||||
projectName: BUILD_JOB,
|
||||
selector: [
|
||||
$class: 'ParameterizedBuildSelector',
|
||||
parameterName: BUILD_JOB_SELECTOR
|
||||
],
|
||||
target: BUILD_ARTIFACTS
|
||||
)
|
||||
def mfs = autobuilderscript.getmetafolderscript()
|
||||
buildmeta = mfs.metafromfolder(BUILD_ARTIFACTS)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Check components') {
|
||||
steps {
|
||||
script {
|
||||
def checker = load("${autobuilder.commonscripts()}/check/do_meta.groovy")
|
||||
(summarystring, markunstable, unstablereason) = checker.checkhierarchy(buildmeta, MAX_META_DEPTH, BUILD_ARTIFACTS)
|
||||
if (markunstable) {
|
||||
env.unstablereason = unstablereason
|
||||
currentBuild.result = 'UNSTABLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archiving artifacts') {
|
||||
steps {
|
||||
script {
|
||||
def artifactlist = meta.generateartifacts()
|
||||
archiveArtifacts "summary/**,${artifactlist}"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Summarise') {
|
||||
steps {
|
||||
script {
|
||||
echo "Summary:\n${summarystring}\n"
|
||||
if (env.unstablereason) {
|
||||
echo "Instability reason: ${env.unstablereason}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'Post-build'
|
||||
}
|
||||
failure {
|
||||
echo 'Failed build'
|
||||
}
|
||||
unstable {
|
||||
echo 'Unstable build'
|
||||
}
|
||||
success {
|
||||
echo 'Succeeded build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
64
check/do_meta.groovy
Normal file
64
check/do_meta.groovy
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
markunstable = false
|
||||
unstablereason = ""
|
||||
|
||||
summaryfolder = "${WORKSPACE}/summary"
|
||||
summaryfile = "${summaryfolder}/summary.txt"
|
||||
summarystring = ""
|
||||
releaserepofolder = "${WORKSPACE}/releaserepos"
|
||||
sourcerepofolder = "${WORKSPACE}/sourcerepos"
|
||||
tempfolder = "${WORKSPACE}/temp"
|
||||
gitrevparseoutputfile = "${tempfolder}/gitrevparse.out"
|
||||
|
||||
metascript = autobuilder.getmetafolderscript()
|
||||
|
||||
def resetfolders() {
|
||||
dir(summaryfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(releaserepofolder) {
|
||||
deleteDir()
|
||||
}
|
||||
dir(tempfolder) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
|
||||
def preconditions() {
|
||||
markunstable = false
|
||||
unstablereason = ""
|
||||
summarystring = ""
|
||||
writeFile(file: summaryfile, text: "Release summary: \n")
|
||||
}
|
||||
|
||||
def setunstable(String reason) {
|
||||
markunstable = true
|
||||
unstablereason += reason + "\n"
|
||||
echo "Marked build as unstable: Reason: ${reason}"
|
||||
}
|
||||
|
||||
def summaryappend(String summary) {
|
||||
def String currentsummarycontents = readFile(file: summaryfile)
|
||||
writeFile(file: summaryfile, text: currentsummarycontents + summary)
|
||||
summarystring += summary
|
||||
}
|
||||
|
||||
def checkhierarchy(buildmeta, String maxdepth, String buildpathroot) {
|
||||
int md = maxdepth.toInteger()
|
||||
resetfolders()
|
||||
preconditions()
|
||||
|
||||
// Walk the meta information to a max depth, looking for components to release
|
||||
def componentReleaseInfo = buildmeta.releasewalkerunique(md)
|
||||
echo "Unique components:"
|
||||
def String versioncomponent = ""
|
||||
for (key in componentReleaseInfo.keySet()) {
|
||||
def buildinfo = componentReleaseInfo[key]
|
||||
def offsetpath = buildinfo.offsetpath
|
||||
versioncomponent += "Key: ${key} Path: ${offsetpath}\n"
|
||||
}
|
||||
echo versioncomponent
|
||||
|
||||
return [summarystring, markunstable, unstablereason]
|
||||
}
|
||||
|
||||
return this;
|
||||
Loading…
Add table
Add a link
Reference in a new issue