diff --git a/autobuilder.groovy b/autobuilder.groovy index 4e04695..2879f11 100644 --- a/autobuilder.groovy +++ b/autobuilder.groovy @@ -44,7 +44,7 @@ def alterreleaserepo(String releaserepo, String releaserepovariantsuffix) { } // Start up boilderplate -def startbuild(script, String productname = PRODUCT_NAME, String subcomponentname = SUBCOMPONENT_NAME, String releaserepo = RELEASE_REPO, String releaserepovariantsuffix = '', String autobuildpath = autobuildroot, String commonscriptspath = commonscriptsroot) { +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 @@ -55,13 +55,13 @@ def startbuild(script, String productname = PRODUCT_NAME, String subcomponentnam def meta = getmetafolderscript().metareset(script) echo "Product name: ${productname} Subcomponent name: ${subcomponentname}" - meta.productinfo.set(productname, 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, releaserepovariantsuffix) + def String alteredreleaserepo = alterreleaserepo(releaserepo, productvariant) echo "Release repo: ${alteredreleaserepo}" rr.registerrepo(meta, alteredreleaserepo) diff --git a/meta/folder.groovy b/meta/folder.groovy index aac8b6c..dcce18d 100644 --- a/meta/folder.groovy +++ b/meta/folder.groovy @@ -23,13 +23,14 @@ class ProductInfo extends GISJsonSerialised { String productname String subcomponentname - ProductInfo(script, productname = "", subcomponentname = "") { + ProductInfo(script, productname = "", subcomponentname = "", variant = "") { super(script) this.productname = productname this.subcomponentname = subcomponentname + this.variant = variant } - void set(String productname, String subcomponentname) { + void set(String productname, String subcomponentname, String variant = '') { // Make sure the fields can be used in git tags def int pstatus = 0 if (script.isUnix()) { @@ -51,19 +52,34 @@ class ProductInfo extends GISJsonSerialised { if (sstatus > 0) { script.error("The subcomponent name: ${subcomponentname} needs to be renamed as it cannot be used in a git tag name") } + if (variant) { + def int sstatus = 0 + if (script.isUnix()) { + sstatus = script.sh(script: "git check-ref-format --normalize \"refs/tags/${variant}\" >/dev/null 2>/dev/null", , returnStatus: true) + } + else { + sstatus = script.bat(script: "@git check-ref-format --normalize \"refs/tags/${variant}\" > NUL 2> NUL", , returnStatus: true) + } + if (sstatus > 0) { + script.error("The subcomponent name: ${variant} needs to be renamed as it cannot be used in a git tag name") + } + } this.productname = productname this.subcomponentname = subcomponentname + this.variant = variant } void deserialiseJson(rawmeta) { productname = rawmeta['productname'] subcomponentname = rawmeta['subcomponentname'] + variant = rawmeta['variant'] ?: "" } LinkedHashMap serialisationdata() { def data = [ 'productname' : productname, 'subcomponentname' : subcomponentname, + 'variant' : variant, ] return data }