From ad00620c74ff87efb91ed4c53d309123d2037e97 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 8 Apr 2019 15:53:44 +0100 Subject: [PATCH 1/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 819a580..d064161 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -30,4 +30,47 @@ def placeBinaries(artifactDetails, installerDetails) { } } -return this; \ No newline at end of file +def checkISMfile(String ISMfile) { + def xmlFile = new File(ISMfile) + + def parsedxml = new XmlParser().parse(xmlFile) + def pathvariableinfo = [:] + def exitcode = 0 + // Load up a map of path variable and path pairs + // Ignore blank path definitions + // Ignore the workspace definition which should have the only absolute path + parsedxml.each{ table -> + if (table.@name == "ISPathVariable") { + table.row.each{ row -> + def pathname = row.td[0].value()[0] + def path = row.td[1].value()[0] + if (path && pathname != "WORKSPACE") { + pathvariableinfo[pathname] = path + } + } + } + } + // Check that each path variable is defined beginning with a path variable or the WORKSPACE one + pathvariableinfo.each{ pair -> + println "pair key: ${pair.key} value: ${pair.value}" + def path = pair.value + def pathvarmatcher = path =~ /<(.*)>.*/ + if (pathvarmatcher.matches()) { + def pathvarfound = pathvarmatcher.group(1) + if (pathvarfound != 'WORKSPACE') { + if (!pathvariableinfo.containsKey(pathvarfound)) { + println "Undefined path variable ${pathvarfound} found" + exitcode = 1 + } + } + } else { + println "Path: ${path} does not begin with a path variable" + exitcode = 1 + } + } + if (exitcode > 0) { + error "The ISM file: ${ISMfile} contains a path that is either absolute or does not begin with another path variable definition" + } +} + +return this; From 1435d338acc9019903594c3b2298bd4ab3150f2b Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 8 Apr 2019 17:58:05 +0100 Subject: [PATCH 2/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index d064161..886c604 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -31,9 +31,9 @@ def placeBinaries(artifactDetails, installerDetails) { } def checkISMfile(String ISMfile) { - def xmlFile = new File(ISMfile) + def xml = readFile(ISMfile) - def parsedxml = new XmlParser().parse(xmlFile) + def parsedxml = new XmlParser().parseText(xml) def pathvariableinfo = [:] def exitcode = 0 // Load up a map of path variable and path pairs From ee7da8715fc2b4f4b8f2fb269207746d83d409ca Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 8 Apr 2019 18:07:31 +0100 Subject: [PATCH 3/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 886c604..6cecb85 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -33,7 +33,7 @@ def placeBinaries(artifactDetails, installerDetails) { def checkISMfile(String ISMfile) { def xml = readFile(ISMfile) - def parsedxml = new XmlParser().parseText(xml) + def parsedxml = new XmlParser(true, true, true).parseText(xml) def pathvariableinfo = [:] def exitcode = 0 // Load up a map of path variable and path pairs From 63202270913c56490108966727ca6edca7e11950 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 8 Apr 2019 18:21:53 +0100 Subject: [PATCH 4/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 6cecb85..f3dcdd4 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -30,6 +30,7 @@ def placeBinaries(artifactDetails, installerDetails) { } } +@NonCPS def checkISMfile(String ISMfile) { def xml = readFile(ISMfile) From 1c10bfba373c73007a0ca0cae5cb2ec611bd0f24 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Mon, 8 Apr 2019 18:30:16 +0100 Subject: [PATCH 5/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index f3dcdd4..823c117 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -33,7 +33,8 @@ def placeBinaries(artifactDetails, installerDetails) { @NonCPS def checkISMfile(String ISMfile) { def xml = readFile(ISMfile) - + echo "Checking ISM file: ${ISMfile}" + def parsedxml = new XmlParser(true, true, true).parseText(xml) def pathvariableinfo = [:] def exitcode = 0 @@ -53,24 +54,26 @@ def checkISMfile(String ISMfile) { } // Check that each path variable is defined beginning with a path variable or the WORKSPACE one pathvariableinfo.each{ pair -> - println "pair key: ${pair.key} value: ${pair.value}" + echo "pair key: ${pair.key} value: ${pair.value}" def path = pair.value def pathvarmatcher = path =~ /<(.*)>.*/ if (pathvarmatcher.matches()) { def pathvarfound = pathvarmatcher.group(1) if (pathvarfound != 'WORKSPACE') { if (!pathvariableinfo.containsKey(pathvarfound)) { - println "Undefined path variable ${pathvarfound} found" + echo "Undefined path variable ${pathvarfound} found" exitcode = 1 } } } else { - println "Path: ${path} does not begin with a path variable" + echo "Path: ${path} does not begin with a path variable" exitcode = 1 } } 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" } } From 08a7350ee8eed79257c89a310a10de6580d04d8c Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 9 Apr 2019 08:39:15 +0100 Subject: [PATCH 6/9] 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}" } } From b7c5f9805b841417dc59a28c2a1fa96fb8374fcf Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 9 Apr 2019 08:57:32 +0100 Subject: [PATCH 7/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 51edd3d..6ac2e80 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -42,10 +42,10 @@ def checkISMfilebackend(String xml) { // Ignore the workspace definition which should have the only absolute path parsedxml.each{ table -> if (table.@name == "ISPathVariable") { - table.row.each{ row -> - def pathname = row.td[0].value()[0] - def path = row.td[1].value()[0] - if (path && pathname != "WORKSPACE") { + table['row'].each{ row -> + def pathname = row['td'][0].value()[0] + def path = row['td'][1].value()[0] + if (path && pathname != 'WORKSPACE') { pathvariableinfo[pathname] = path } } From f141d804103ce3301c18dbe79cdeaf10fd61d188 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 9 Apr 2019 09:30:24 +0100 Subject: [PATCH 8/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 6ac2e80..ca9c502 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -78,6 +78,9 @@ def checkISMfile(String ISMfile) { (exitcode, message) = checkISMfilebackend(xml) if (exitcode > 0) { error "ISM file errors found:\n${message}" + } else { + echo "Checked ISM file: ${ISMfile} - ok" + echo message } } From 2317111f3bde99ef2feae3a6feaaade1dd78868d Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Tue, 9 Apr 2019 10:44:43 +0100 Subject: [PATCH 9/9] Perform installer file (ISM) checking --- install/installhelper.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index ca9c502..1464e9d 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -76,11 +76,11 @@ def checkISMfile(String ISMfile) { echo "Checking ISM file: ${ISMfile}" def xml = readFile(ISMfile) (exitcode, message) = checkISMfilebackend(xml) + echo message if (exitcode > 0) { - error "ISM file errors found:\n${message}" + error "ISM file errors found" } else { - echo "Checked ISM file: ${ISMfile} - ok" - echo message + echo "Checked ISM file - ok" } }