131 lines
4 KiB
Groovy
131 lines
4 KiB
Groovy
// Assume that WORKSPACE environment variable is set
|
|
|
|
autobuildroot = '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
|
|
def stashname = 'Clean workspace stash'
|
|
stash(allowEmpty: true,
|
|
includes: "${autobuildroot}/**,${autobuildroot}/.git/**",
|
|
name: stashname,
|
|
useDefaultExcludes: false
|
|
)
|
|
cleanWs()
|
|
unstash name: stashname
|
|
}
|
|
else {
|
|
echo "Not cleaning workspace"
|
|
}
|
|
}
|
|
|
|
def commonscripts() {
|
|
return commonscriptsroot
|
|
}
|
|
|
|
def getautobuildpath() {
|
|
return autobuildroot
|
|
}
|
|
|
|
def getmetafolderscript() {
|
|
return metafolderscript
|
|
}
|
|
|
|
def alterreleaserepo(String releaserepo, String releaserepovariantsuffix) {
|
|
def String altered = releaserepo.trim()
|
|
|
|
if (releaserepovariantsuffix?.trim()) {
|
|
altered = altered.replace("-RELEASE_REPO_VARIANT_SUFFIX-", releaserepovariantsuffix)
|
|
}
|
|
return altered
|
|
}
|
|
|
|
// Start up boilerplate
|
|
def startbuild(
|
|
script,
|
|
String productname = PRODUCT_NAME,
|
|
String subcomponentname = SUBCOMPONENT_NAME,
|
|
String releaserepo = RELEASE_REPO,
|
|
String productvariant = '',
|
|
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, productvariant)
|
|
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")
|
|
def String alteredreleaserepo = alterreleaserepo(releaserepo, productvariant)
|
|
|
|
echo "Release repo: ${alteredreleaserepo}"
|
|
rr.registerrepo(meta, alteredreleaserepo)
|
|
|
|
def ch = load("${commonscripts()}/configuration/configuration.groovy")
|
|
ch.registerPipelineScriptConfiguration(meta)
|
|
|
|
return meta
|
|
}
|
|
|
|
// DEPRECATED Metod, Use StartBuild Instead.
|
|
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;
|