Skip to content

Commit 83cf49b

Browse files
conditions and required params check
1 parent 74ead2a commit 83cf49b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

plugin.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,24 @@ func (p Plugin) Exec() error {
434434

435435
if os.IsNotExist(err) || !p.Config.UseSonarConfigFile {
436436
// If the configuration file does not exist, use the default parameters
437-
fmt.Println("Configuration file not found. Using default parameters.")
437+
fmt.Println("Configuration file not found or sonar_config_file not set to true. Using plugin's parameters.")
438438
args = []string{
439439
"-Dsonar.host.url=" + p.Config.Host,
440440
"-Dsonar.login=" + p.Config.Token,
441441
}
442442

443+
if len(p.Config.Host) < 1 || len(p.Config.Token) < 1 {
444+
fmt.Println("sonar_token and sonar_host params are mandatory.")
445+
fmt.Println("Exiting with status 2")
446+
os.Exit(2)
447+
}
448+
449+
if len(p.Config.Key) < 1 {
450+
fmt.Println("sonar_key (prject key) param is mandatory.")
451+
fmt.Println("Exiting with status 2")
452+
os.Exit(2)
453+
}
454+
443455
// Map of potential configurations
444456
configurations := map[string]string{
445457
"-Dsonar.projectKey": p.Config.Key,

0 commit comments

Comments
 (0)