Copy from Atlas Autobuild scripts as a starting point

This commit is contained in:
Dan Hawkins 2020-10-22 12:12:30 +01:00
commit 2d66e342df
92 changed files with 11897 additions and 0 deletions

View 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'
}
}
}

View file

@ -0,0 +1,77 @@
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
def buildinfo = buildmeta.releasewalker(md)
echo "All components:"
def String componentinfo = ""
for (entry in buildinfo) {
def name = entry.meta.componentversionuniqueidentifier()
def offsetpath = entry.offsetpath
def abspath = "${buildpathroot}/${offsetpath}"
componentinfo += "Name: ${name} \t\t\t\tPath: ${offsetpath} \t\t\t\tFile exists in import: ${fileExists(abspath)}\n"
}
echo componentinfo
// Walk the meta information to a max depth
def componentReleaseInfo = buildmeta.releasewalkerunique(md)
echo "Unique components:"
def String versioncomponent = ""
for (key in componentReleaseInfo.keySet()) {
def buildinfo2 = componentReleaseInfo[key]
def offsetpath = buildinfo2.offsetpath
def abspath = "${buildpathroot}/${offsetpath}"
versioncomponent += "Key: ${key} \t\t\tPath: ${offsetpath} \t\t\tFile exists in import: ${fileExists(abspath)}\n"
}
echo versioncomponent
return [summarystring, markunstable, unstablereason]
}
return this;