Skip to content

Commit 7e25c5c

Browse files
author
Lars Brillert
committed
sonar-scanner will wait for the quality gate if -Dsonar.qualitygate.wait is set to true
there's no need to wait in the code itself. So when waiting is disabled we'll not wait for the gate and just continue
1 parent c2b5ca3 commit 7e25c5c

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

plugin.go

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -550,29 +550,40 @@ func (p Plugin) Exec() error {
550550
"error": err,
551551
}).Fatal("Unable to parse scan results!")
552552
}
553-
logrus.WithFields(logrus.Fields{
554-
"job url": report.CeTaskURL,
555-
}).Info("Job url")
556-
fmt.Printf("\n")
557-
fmt.Printf("\n\nWaiting Analysis to finish:\n\n")
558-
fmt.Printf("\n")
559-
560-
task, err := waitForSonarJob(report)
561553

562-
if err != nil {
554+
if p.Config.WaitQualityGate {
563555
logrus.WithFields(logrus.Fields{
564-
"error": err,
565-
}).Fatal("Unable to get Job state")
566-
return err
567-
}
556+
"job url": report.CeTaskURL,
557+
}).Info("Job url")
558+
fmt.Printf("\n")
559+
fmt.Printf("\n\nWaiting Analysis to finish:\n\n")
560+
fmt.Printf("\n")
568561

569-
fmt.Printf("\n")
570-
fmt.Printf("#######################################\n")
571-
fmt.Printf("Waiting for quality gate validation...\n")
572-
fmt.Printf("#######################################\n")
573-
fmt.Printf("\n")
562+
task, err := waitForSonarJob(report)
563+
564+
if err != nil {
565+
logrus.WithFields(logrus.Fields{
566+
"error": err,
567+
}).Fatal("Unable to get Job state")
568+
return err
569+
}
570+
571+
fmt.Printf("\n")
572+
fmt.Printf("#######################################\n")
573+
fmt.Printf("Waiting for quality gate validation...\n")
574+
fmt.Printf("#######################################\n")
575+
fmt.Printf("\n")
576+
577+
status = getStatus(task, report)
578+
} else {
579+
fmt.Printf("\n")
580+
fmt.Printf("#######################################\n")
581+
fmt.Printf("Delaying for quality gate validation...\n")
582+
fmt.Printf("#######################################\n")
583+
fmt.Printf("\n")
574584

575-
status = getStatus(task, report)
585+
status = "OK"
586+
}
576587
}
577588

578589
fmt.Printf("\n")
@@ -596,7 +607,7 @@ func (p Plugin) Exec() error {
596607
// fmt.Printf("\n==> FAILED <==\n")
597608
logrus.WithFields(logrus.Fields{
598609
"status": status,
599-
}).Info("Quality Gate Status FAILED")
610+
}).Info("Quality Gate Status disabled")
600611
}
601612
if status == p.Config.Quality {
602613
// fmt.Printf("\n==> QUALITY GATEWAY ENALED \n")

0 commit comments

Comments
 (0)