HMBFDHV-560 - Store product variant in meta productinfo

This commit is contained in:
Dan Hawkins 2021-02-26 18:03:55 +00:00
commit 0b360fcd92
2 changed files with 21 additions and 5 deletions

View file

@ -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)

View file

@ -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
}