Skip to content

Commit 966bbf9

Browse files
authored
Merge branch 'master' into fix_app_name
2 parents f062ef4 + 0c41f9c commit 966bbf9

6 files changed

+35
-27
lines changed

cmd/detectExecuteScan.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,11 @@ func getDetectScript(config detectExecuteScanOptions, utils detectUtils) error {
427427
log.Entry().Infof("Downloading Detect Script")
428428

429429
downloadScript := func() error {
430-
if config.UseDetect9 {
431-
return utils.DownloadFile("https://detect.synopsys.com/detect9.sh", "detect.sh", nil, nil)
430+
if config.UseDetect8 {
431+
return utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil)
432432
}
433-
return utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil)
433+
return utils.DownloadFile("https://detect.synopsys.com/detect9.sh", "detect.sh", nil, nil)
434+
434435
}
435436

436437
if err := downloadScript(); err != nil {

cmd/detectExecuteScan_generated.go

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/detectExecuteScan_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func TestRunDetect(t *testing.T) {
310310
utilsMock.AddFile("detect.sh", []byte(""))
311311
err := runDetect(ctx, detectExecuteScanOptions{}, utilsMock, &detectExecuteScanInflux{})
312312

313-
assert.Equal(t, utilsMock.downloadedFiles["https://detect.synopsys.com/detect8.sh"], "detect.sh")
313+
assert.Equal(t, utilsMock.downloadedFiles["https://detect.synopsys.com/detect9.sh"], "detect.sh")
314314
assert.True(t, utilsMock.HasRemovedFile("detect.sh"))
315315
assert.NoError(t, err)
316316
assert.Equal(t, ".", utilsMock.Dir, "Wrong execution directory used")

pkg/vault/client.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,33 @@ func NewClientWithToken(cfg *ClientConfig, token string) (*Client, error) {
8282
func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) {
8383
defer func() {
8484
// make sure to close channel to avoid blocking of the caller
85-
_, open := <-initialLoginDone
86-
if open {
87-
close(initialLoginDone)
88-
}
85+
log.Entry().Debugf("exiting Vault token lifecycle manager")
86+
initialLoginDone <- struct{}{}
87+
close(initialLoginDone)
8988
}()
9089

9190
initialLoginSucceed := false
92-
for i := 0; i < c.vaultApiClient.MaxRetries(); i++ {
91+
retryAttemptDuration := c.vaultApiClient.MinRetryWait()
92+
for i := 0; i <= c.vaultApiClient.MaxRetries(); i++ {
93+
if i != 0 {
94+
log.Entry().Infof("Retrying Vault login in %.0f seconds. Attempt %d of %d",
95+
retryAttemptDuration.Seconds(), i, c.vaultApiClient.MaxRetries())
96+
time.Sleep(retryAttemptDuration)
97+
}
98+
9399
vaultLoginResp, err := c.login()
94100
if err != nil {
95-
log.Entry().Errorf("unable to authenticate to Vault: %v", err)
101+
log.Entry().Warnf("unable to authenticate to Vault: %v", err)
96102
continue
97103
}
98104
if !initialLoginSucceed {
99105
initialLoginDone <- struct{}{}
100-
close(initialLoginDone)
101106
initialLoginSucceed = true
102107
}
103108

104109
tokenErr := c.manageTokenLifecycle(vaultLoginResp)
105110
if tokenErr != nil {
106-
log.Entry().Errorf("unable to start managing token lifecycle: %v", err)
111+
log.Entry().Warnf("unable to start managing token lifecycle: %v", err)
107112
continue
108113
}
109114
}

resources/metadata/detectExecuteScan.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,11 @@ spec:
653653
resourceRef:
654654
- name: commonPipelineEnvironment
655655
param: container/repositoryPassword
656-
- name: useDetect9
656+
- name: useDetect8
657657
description:
658-
"This flag enables the use of the supported version 9 of the Detect Script instead of v8"
658+
"This flag enables the use of the supported version 8 of the Detect Script instead of v9"
659659
aliases:
660-
- name: detect/useDetect9
660+
- name: detect/useDetect8
661661
type: bool
662662
scope:
663663
- PARAMETERS

vars/sonarExecuteScan.groovy

+10-8
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,19 @@ void call(Map parameters = [:]) {
6565
writePipelineEnv(script: script, piperGoPath: piperGoPath)
6666
withEnv(environment) {
6767
influxWrapper(script) {
68-
piperExecuteBin.credentialWrapper(config, credentialInfo) {
69-
if (stepConfig.instance) {
70-
withSonarQubeEnv(stepConfig.instance) {
71-
echo "Instance is deprecated - please use serverUrl parameter to set URL to the Sonar backend."
68+
try {
69+
piperExecuteBin.credentialWrapper(config, credentialInfo) {
70+
if (stepConfig.instance) {
71+
withSonarQubeEnv(stepConfig.instance) {
72+
echo "Instance is deprecated - please use serverUrl parameter to set URL to the Sonar backend."
73+
sh "${piperGoPath} ${STEP_NAME}${customDefaultConfig}${customConfigArg}"
74+
}
75+
} else {
7276
sh "${piperGoPath} ${STEP_NAME}${customDefaultConfig}${customConfigArg}"
73-
jenkinsUtils.handleStepResults(STEP_NAME, false, false)
74-
readPipelineEnv(script: script, piperGoPath: piperGoPath)
7577
}
76-
} else {
77-
sh "${piperGoPath} ${STEP_NAME}${customDefaultConfig}${customConfigArg}"
7878
}
79+
} finally {
80+
jenkinsUtils.handleStepResults(STEP_NAME, false, false)
7981
}
8082
}
8183
}

0 commit comments

Comments
 (0)