Skip to content

Commit 0ca9203

Browse files
Merge pull request #90 from diegopereiraeng/main
workspace relative path fix - only affected by the new param workspace - solution
2 parents 8624485 + 73b4ad2 commit 0ca9203

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ steps:
1919
when:
2020
ref:
2121
- "refs/pull/**" # Only run for pull requests
22-
- name: publish-2.2.0
22+
- name: publish-2.2.1
2323
image: plugins/docker:20
2424
settings:
2525
# auto_tag: true
2626
# auto_tag_suffix: v2.0.2-java17
2727
tags:
28-
- v2.2.0
28+
- v2.2.1
2929
# - latest
3030
# - stable-java17
3131
daemon_off: false

plugin.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,11 @@ func (p Plugin) Exec() error {
473473
params := strings.Split(p.Config.CustomJvmParams, ",")
474474
args = append(args, params...)
475475
}
476-
476+
taskFilePath := ".scannerwork/report-task.txt"
477+
477478
if len(p.Config.Workspace) >= 1 {
478479
args = append(args, "-Dsonar.projectBaseDir="+p.Config.Workspace)
480+
taskFilePath = p.Config.Workspace+"/.scannerwork/report-task.txt"
479481
}
480482

481483
// Assuming your struct has a print or log method
@@ -531,7 +533,7 @@ func (p Plugin) Exec() error {
531533
fmt.Printf("\n==> Sonar Analysis Finished!\n\n")
532534
fmt.Printf("\n\nStatic Analysis Result:\n\n")
533535

534-
cmd = exec.Command("cat", ".scannerwork/report-task.txt")
536+
cmd = exec.Command("cat", taskFilePath)
535537

536538
cmd.Stdout = os.Stdout
537539

@@ -553,7 +555,7 @@ func (p Plugin) Exec() error {
553555
fmt.Printf("\n\nParsing Results:\n\n")
554556
fmt.Printf("\n")
555557

556-
report, err := staticScan(&p)
558+
report, err := staticScan(&p, taskFilePath)
557559

558560
if err != nil {
559561
logrus.WithFields(logrus.Fields{
@@ -644,9 +646,9 @@ func displayQualityGateStatus(status string, qualityEnabled bool) {
644646
fmt.Println(lineBreak)
645647
}
646648

647-
func staticScan(p *Plugin) (*SonarReport, error) {
649+
func staticScan(p *Plugin, taskFilePath string) (*SonarReport, error) {
648650

649-
cmd := exec.Command("sed", "-e", "s/=/=\"/", "-e", "s/$/\"/", ".scannerwork/report-task.txt")
651+
cmd := exec.Command("sed", "-e", "s/=/=\"/", "-e", "s/$/\"/", taskFilePath)
650652
output, err := cmd.CombinedOutput()
651653
if err != nil {
652654
logrus.WithFields(logrus.Fields{

0 commit comments

Comments
 (0)