diff --git a/pkg/piperenv/CPEMap.go b/pkg/piperenv/CPEMap.go index 5e9163271..c43a7c0fb 100644 --- a/pkg/piperenv/CPEMap.go +++ b/pkg/piperenv/CPEMap.go @@ -3,6 +3,7 @@ package piperenv import ( "encoding/json" "fmt" + "github.com/SAP/jenkins-library/pkg/log" "io/ioutil" "os" "path" @@ -62,7 +63,8 @@ func (c CPEMap) WriteToDisk(rootDirectory string) error { func dirToMap(m map[string]interface{}, dirPath, prefix string) error { if stat, err := os.Stat(dirPath); err != nil || !stat.IsDir() { - return fmt.Errorf("stat on '%s' failed. Not a dir?: %w", dirPath, err) + log.Entry().Debugf("stat on %s failed. Path does not exist", dirPath) + return nil } items, err := ioutil.ReadDir(dirPath) diff --git a/pkg/piperenv/CPEMap_test.go b/pkg/piperenv/CPEMap_test.go index b34f0a297..cab4f45ef 100644 --- a/pkg/piperenv/CPEMap_test.go +++ b/pkg/piperenv/CPEMap_test.go @@ -84,3 +84,10 @@ func TestCPEMap_LoadFromDisk(t *testing.T) { assert.Equal(t, "Wayne", cpe["Batman/Bruce"]) assert.Equal(t, float64(54), cpe["Batman/Test"]) } + +func TestCommonPipelineEnvDirNotPresent(t *testing.T) { + cpe := CPEMap{} + err := cpe.LoadFromDisk("/path/does/not/exist") + assert.NoError(t, err) + assert.Len(t, cpe, 0) +} diff --git a/vars/sonarExecuteScan.groovy b/vars/sonarExecuteScan.groovy index 259170744..f842befca 100644 --- a/vars/sonarExecuteScan.groovy +++ b/vars/sonarExecuteScan.groovy @@ -60,6 +60,7 @@ void call(Map parameters = [:]) { piperExecuteBin.dockerWrapper(script, STEP_NAME, config){ if(!fileExists('.git')) utils.unstash('git') piperExecuteBin.handleErrorDetails(STEP_NAME) { + writePipelineEnv(script: script, piperGoPath: piperGoPath) withSonarQubeEnv(stepConfig.instance) { withEnv(environment){ influxWrapper(script){