mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-06 04:13:55 +02:00
whitesourceExecuteScan: Avoid downloaded node_modules are treated like project modules
This commit is contained in:
parent
551c2719b7
commit
eeee3a7189
@ -3,10 +3,14 @@ package com.sap.piper.mta
|
|||||||
class MtaMultiplexer implements Serializable {
|
class MtaMultiplexer implements Serializable {
|
||||||
static Map createJobs(Script step, Map parameters, List excludeList, String jobPrefix, String buildDescriptorFile, String scanType, Closure worker) {
|
static Map createJobs(Script step, Map parameters, List excludeList, String jobPrefix, String buildDescriptorFile, String scanType, Closure worker) {
|
||||||
Map jobs = [:]
|
Map jobs = [:]
|
||||||
def filesToScan
|
def filesToScan = []
|
||||||
|
|
||||||
filesToScan = step.findFiles(glob: "**${File.separator}${buildDescriptorFile}")
|
// avoid java.io.NotSerializableException: org.codehaus.groovy.util.ArrayIterator
|
||||||
step.echo "Found ${filesToScan.length} ${scanType} descriptor files!"
|
// 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)
|
filesToScan = removeExcludedFiles(step, filesToScan, excludeList)
|
||||||
|
|
||||||
for (String file : filesToScan){
|
for (String file : filesToScan){
|
||||||
@ -19,6 +23,17 @@ class MtaMultiplexer implements Serializable {
|
|||||||
return jobs
|
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){
|
static def removeExcludedFiles(Script step, filesToScan, List filesToExclude){
|
||||||
def filteredFiles = []
|
def filteredFiles = []
|
||||||
for (File file : filesToScan) {
|
for (File file : filesToScan) {
|
||||||
|
Loading…
Reference in New Issue
Block a user