1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-18 05:18:24 +02:00

fix(whitesourceExecuteScan) npm modules only (#2670)

do not fail step in case mta contains only node modules.
No pom.xml required then.

Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
This commit is contained in:
Oliver Nocon 2021-03-04 10:38:57 +01:00 committed by GitHub
parent cc66b7cabd
commit 4f9eff2303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -27,9 +27,9 @@ func (s *Scan) ExecuteUAScan(config *ScanOptions, utils Utils) error {
return errors.Wrap(err, "failed to run scan for maven modules of mta")
}
} else {
// ToDo: only warning message?
//log.Entry().Warning("MTA project does not contain a pom.xml in the root. Scan results might be incomplete")
return fmt.Errorf("mta project does not contain an aggregator pom.xml in the root - this is mandatory")
if pomFiles, _ := utils.Glob("**/pom.xml"); len(pomFiles) > 0 {
return fmt.Errorf("mta project with java modules does not contain an aggregator pom.xml in the root - this is mandatory")
}
}
packageJSONFiles, err := utils.FindPackageJSONFiles(config)

View File

@ -68,10 +68,24 @@ func TestExecuteUAScan(t *testing.T) {
ProductName: "test-product",
}
utilsMock := NewScanUtilsMock()
utilsMock.AddFile(filepath.Join("sub", "pom.xml"), []byte("dummy"))
scan := newTestScan(&config)
err := scan.ExecuteUAScan(&config, utilsMock)
assert.EqualError(t, err, "mta project does not contain an aggregator pom.xml in the root - this is mandatory")
assert.EqualError(t, err, "mta project with java modules does not contain an aggregator pom.xml in the root - this is mandatory")
})
t.Run("error - no pom.xml & only npm", func(t *testing.T) {
config := ScanOptions{
BuildTool: "mta",
ProjectName: "test-project",
ProductName: "test-product",
}
utilsMock := NewScanUtilsMock()
scan := newTestScan(&config)
err := scan.ExecuteUAScan(&config, utilsMock)
assert.NoError(t, err)
})
t.Run("error - npm no name", func(t *testing.T) {