mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-04 04:07:16 +02:00
[CPE] Missing pipeline environment in sonar docker container (#2909)
* execute writepipeline env in sonar * non exisitng dir is no error * add log message
This commit is contained in:
parent
0b48bfcc73
commit
173e887064
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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){
|
||||
|
Loading…
Reference in New Issue
Block a user