Pass script object to custom objects

This commit is contained in:
Dan Hawkins 2018-11-19 17:30:30 +00:00
commit 46cd0d3d87
2 changed files with 10 additions and 8 deletions

View file

@ -26,7 +26,7 @@ def getautobuildpath() {
}
// Start up boilderplate
def start(productname = PRODUCT_NAME, subcomponentname = SUBCOMPONENT_NAME, jirakey = JIRA_KEY, autobuildpath = autobuildroot, commonscriptspath = commonscriptsroot) {
def start(script, productname = PRODUCT_NAME, subcomponentname = SUBCOMPONENT_NAME, jirakey = JIRA_KEY, autobuildpath = autobuildroot, commonscriptspath = commonscriptsroot) {
echo "Starting...."
autobuildroot = autobuildpath
@ -38,7 +38,7 @@ def start(productname = PRODUCT_NAME, subcomponentname = SUBCOMPONENT_NAME, jira
metafolder.metareset()
def productinfo = load("${commonscripts()}/product/info.groovy")
productinfo.setname(productname, subcomponentname, jirakey)
productinfo.setname(script, productname, subcomponentname, jirakey)
def ch = load("${commonscripts()}/configuration/configuration.groovy")
ch.registerPipelineScriptConfiguration()

View file

@ -5,12 +5,14 @@ metafolder = load("${autobuilder.commonscripts()}/meta/folder.groovy")
PRODUCTFOLDER = "${metafolder.METAFOLDERNAME}/product"
env.PRODUCTARTIFACTS = "${PRODUCTFOLDER}/**"
class ProductInfo {
class ProductInfo implements Serializable {
private script
private String productname
private String subcomponentname
private String jirakey
ProductInfo(productName = "", subcomponentName = "", jiraKey = "") {
ProductInfo(script, productName = "", subcomponentName = "", jiraKey = "") {
this.script = script
super()
productname = productName
subcomponentname = subcomponentName
@ -26,7 +28,7 @@ class ProductInfo {
return data
}
def saveJsonSerialised(script, String outputfile, int prettylevel = 4) {
def saveJsonSerialised(String outputfile, int prettylevel = 4) {
def outJson = script.readJSON text: groovy.json.JsonOutput.toJson(serialisationdata())
script.writeJSON(file: outputfile, json: outJson, pretty: prettylevel)
}
@ -34,11 +36,11 @@ class ProductInfo {
theProductInfo = new ProductInfo()
def setname(productname = PRODUCT_NAME, subcomponentname = SUBCOMPONENT_NAME, jirakey = JIRA_KEY) {
theProductInfo = new ProductInfo(productname, subcomponentname, jirakey)
def setname(script, productname = PRODUCT_NAME, subcomponentname = SUBCOMPONENT_NAME, jirakey = JIRA_KEY) {
theProductInfo = new ProductInfo(script, productname, subcomponentname, jirakey)
def PRODUCTFILE = "${PRODUCTFOLDER}/info.json"
theProductInfo.saveJsonSerialised(this, PRODUCTFILE)
theProductInfo.saveJsonSerialised(PRODUCTFILE)
}
return this;