firmware_tools/autobuilder.groovy
2020-02-26 08:52:29 +00:00

93 lines
3.3 KiB
Groovy

// Assume that WORKSPACE environment variable is set
autobuildroot = "${WORKSPACE}/autobuild"
commonscriptsroot = "${autobuildroot}/Common_scripts"
metafolderscript = null
def conditionalclean(doclean = "${CLEAN_WORKSPACE}" == "true") {
if (doclean) {
echo "Cleaning workspace"
// Save any script files that were loaded into the workspace at first and are required after cleaning the workspace
stash allowEmpty: true, includes: 'autobuild/**', name: 'Clean workspace stash', useDefaultExcludes: false
cleanWs()
unstash name: 'Clean workspace stash'
}
else {
echo "Not cleaning workspace"
}
}
def commonscripts() {
return commonscriptsroot
}
def getautobuildpath() {
return autobuildroot
}
def getmetafolderscript() {
return metafolderscript
}
// Start up boilderplate
def startbuild(script, String productname = PRODUCT_NAME, String subcomponentname = SUBCOMPONENT_NAME, String releaserepo = RELEASE_REPO, String autobuildpath = autobuildroot, String commonscriptspath = commonscriptsroot) {
echo "Starting...."
autobuildroot = autobuildpath
commonscriptsroot = commonscriptspath
metafolderscript = load("${commonscripts()}/meta/folder.groovy")
conditionalclean()
def meta = getmetafolderscript().metareset(script)
echo "Product name: ${productname} Subcomponent name: ${subcomponentname}"
meta.productinfo.set(productname, subcomponentname)
def now = new Date()
now.format("yyMMdd.HHmm", TimeZone.getTimeZone('UTC'))
meta.jenkinsbuildinfo.set(JOB_NAME, BUILD_ID.toInteger(), NODE_NAME, now.toString())
def rr = load("${commonscripts()}/release/registerrepo.groovy")
echo "Release repo: ${releaserepo}"
rr.registerrepo(meta, releaserepo)
def ch = load("${commonscripts()}/configuration/configuration.groovy")
ch.registerPipelineScriptConfiguration(meta)
return meta
}
def start(script, String productname = PRODUCT_NAME, String subcomponentname = SUBCOMPONENT_NAME, String jirakey = JIRA_KEY, String releaserepo = RELEASE_REPO, String repoRootSuffix = "", String autobuildpath = autobuildroot, String commonscriptspath = commonscriptsroot) {
echo "DEPRECATED method: start(script, String productname = PRODUCT_NAME, subcomponentname = SUBCOMPONENT_NAME, jirakey = JIRA_KEY, ...)"
return startbuild(script, productname, subcomponentname, releaserepo, autobuildpath, commonscriptspath)
}
// Start up boilderplate
def startnonbuild(script, autobuildpath = autobuildroot, commonscriptspath = commonscriptsroot) {
echo "Starting non-build job...."
autobuildroot = autobuildpath
commonscriptsroot = commonscriptspath
metafolderscript = load("${commonscripts()}/meta/folder.groovy")
conditionalclean()
def meta = getmetafolderscript().metareset(script)
meta.productinfo.set("Non-build-product", "Non-build-subcomponent")
def now = new Date()
now.format("yyMMdd.HHmm", TimeZone.getTimeZone('UTC'))
meta.jenkinsbuildinfo.set(JOB_NAME, BUILD_ID.toInteger(), NODE_NAME, now.toString())
def ch = load("${commonscripts()}/configuration/configuration.groovy")
ch.registerPipelineScriptConfiguration(meta)
return meta
}
def configurationhelper() {
return load("${commonscripts()}/configuration/configuration.groovy")
}
// Everyone wants to know this
autobuilder = this
return this;