From 16ff70565612f9ef6590e8c4c3c928b6ed66e27e Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 9 Apr 2019 08:39:15 +0100 Subject: [PATCH] Perform installer file (ISM) checking --- install/installhelper.groovy | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 823c117..51edd3d 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -31,9 +31,8 @@ def placeBinaries(artifactDetails, installerDetails) { } @NonCPS -def checkISMfile(String ISMfile) { - def xml = readFile(ISMfile) - echo "Checking ISM file: ${ISMfile}" +def checkISMfilebackend(String xml) { + def String message = "" def parsedxml = new XmlParser(true, true, true).parseText(xml) def pathvariableinfo = [:] @@ -54,26 +53,31 @@ def checkISMfile(String ISMfile) { } // Check that each path variable is defined beginning with a path variable or the WORKSPACE one pathvariableinfo.each{ pair -> - echo "pair key: ${pair.key} value: ${pair.value}" + message += "pair key: ${pair.key} value: ${pair.value}\n" def path = pair.value def pathvarmatcher = path =~ /<(.*)>.*/ if (pathvarmatcher.matches()) { def pathvarfound = pathvarmatcher.group(1) if (pathvarfound != 'WORKSPACE') { if (!pathvariableinfo.containsKey(pathvarfound)) { - echo "Undefined path variable ${pathvarfound} found" + message += "Undefined path variable ${pathvarfound} found\n" exitcode = 1 } } } else { - echo "Path: ${path} does not begin with a path variable" + message += "Path: ${path} does not begin with a path variable\n" exitcode = 1 } } + return [exitcode, message] +} + +def checkISMfile(String ISMfile) { + echo "Checking ISM file: ${ISMfile}" + def xml = readFile(ISMfile) + (exitcode, message) = checkISMfilebackend(xml) if (exitcode > 0) { - error "The ISM file: ${ISMfile} contains a path that is either absolute or does not begin with another path variable definition" - } else { - echo "ISM file: ${ISMfile} - ok" + error "ISM file errors found:\n${message}" } }