1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

whitesourceExecuteScan: Avoid downloaded node_modules are treated like project modules

This commit is contained in:
Sven Merk 2019-12-16 09:22:40 +01:00 committed by GitHub
parent 551c2719b7
commit eeee3a7189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {