From eeee3a7189e6cac05f32f0ada43279e385e1a3c7 Mon Sep 17 00:00:00 2001 From: Sven Merk <33895725+nevskrem@users.noreply.github.com> Date: Mon, 16 Dec 2019 09:22:40 +0100 Subject: [PATCH] whitesourceExecuteScan: Avoid downloaded node_modules are treated like project modules --- src/com/sap/piper/mta/MtaMultiplexer.groovy | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/com/sap/piper/mta/MtaMultiplexer.groovy b/src/com/sap/piper/mta/MtaMultiplexer.groovy index 3f19a504e..da1e348e8 100644 --- a/src/com/sap/piper/mta/MtaMultiplexer.groovy +++ b/src/com/sap/piper/mta/MtaMultiplexer.groovy @@ -3,10 +3,14 @@ package com.sap.piper.mta class MtaMultiplexer implements Serializable { static Map createJobs(Script step, Map parameters, List excludeList, String jobPrefix, String buildDescriptorFile, String scanType, Closure worker) { Map jobs = [:] - def filesToScan + def filesToScan = [] - filesToScan = step.findFiles(glob: "**${File.separator}${buildDescriptorFile}") - step.echo "Found ${filesToScan.length} ${scanType} descriptor files!" + // avoid java.io.NotSerializableException: org.codehaus.groovy.util.ArrayIterator + // see https://issues.jenkins-ci.org/browse/JENKINS-47730 + filesToScan.addAll(step.findFiles(glob: "**${File.separator}${buildDescriptorFile}")?:[]) + step.echo "Found ${filesToScan?.size()} ${scanType} descriptor files: ${filesToScan}" + + filesToScan = removeNodeModuleFiles(step, filesToScan) filesToScan = removeExcludedFiles(step, filesToScan, excludeList) for (String file : filesToScan){ @@ -19,6 +23,17 @@ class MtaMultiplexer implements Serializable { return jobs } + static def removeNodeModuleFiles(Script step, filesToScan){ + step.echo "Excluding node modules:" + return filesToScan.findAll({ + if(it.path.contains("node_modules${File.separator}")){ + step.echo "- Skipping ${it.path}" + return false + } + return true + }) + } + static def removeExcludedFiles(Script step, filesToScan, List filesToExclude){ def filteredFiles = [] for (File file : filesToScan) {