Perform installer file (ISM) checking

This commit is contained in:
Dan Hawkins 2019-04-09 08:39:15 +01:00
commit 16ff705656

View file

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