github.com/xgoffin/jenkins-library@v1.154.0/cmd/sonarExecuteScan_generated.go (about) 1 // Code generated by piper's step-generator. DO NOT EDIT. 2 3 package cmd 4 5 import ( 6 "fmt" 7 "os" 8 "path/filepath" 9 "reflect" 10 "strings" 11 "time" 12 13 "github.com/SAP/jenkins-library/pkg/config" 14 "github.com/SAP/jenkins-library/pkg/gcs" 15 "github.com/SAP/jenkins-library/pkg/log" 16 "github.com/SAP/jenkins-library/pkg/piperenv" 17 "github.com/SAP/jenkins-library/pkg/splunk" 18 "github.com/SAP/jenkins-library/pkg/telemetry" 19 "github.com/SAP/jenkins-library/pkg/validation" 20 "github.com/bmatcuk/doublestar" 21 "github.com/spf13/cobra" 22 ) 23 24 type sonarExecuteScanOptions struct { 25 Instance string `json:"instance,omitempty"` 26 ServerURL string `json:"serverUrl,omitempty"` 27 Token string `json:"token,omitempty"` 28 Organization string `json:"organization,omitempty"` 29 CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"` 30 SonarScannerDownloadURL string `json:"sonarScannerDownloadUrl,omitempty"` 31 VersioningModel string `json:"versioningModel,omitempty" validate:"possible-values=major major-minor semantic full"` 32 Version string `json:"version,omitempty"` 33 CustomScanVersion string `json:"customScanVersion,omitempty"` 34 ProjectKey string `json:"projectKey,omitempty"` 35 CoverageExclusions []string `json:"coverageExclusions,omitempty"` 36 InferJavaBinaries bool `json:"inferJavaBinaries,omitempty"` 37 InferJavaLibraries bool `json:"inferJavaLibraries,omitempty"` 38 Options []string `json:"options,omitempty"` 39 BranchName string `json:"branchName,omitempty"` 40 InferBranchName bool `json:"inferBranchName,omitempty"` 41 ChangeID string `json:"changeId,omitempty"` 42 ChangeBranch string `json:"changeBranch,omitempty"` 43 ChangeTarget string `json:"changeTarget,omitempty"` 44 PullRequestProvider string `json:"pullRequestProvider,omitempty" validate:"possible-values=GitHub"` 45 Owner string `json:"owner,omitempty"` 46 Repository string `json:"repository,omitempty"` 47 GithubToken string `json:"githubToken,omitempty"` 48 DisableInlineComments bool `json:"disableInlineComments,omitempty"` 49 LegacyPRHandling bool `json:"legacyPRHandling,omitempty"` 50 GithubAPIURL string `json:"githubApiUrl,omitempty"` 51 M2Path string `json:"m2Path,omitempty"` 52 } 53 54 type sonarExecuteScanReports struct { 55 } 56 57 func (p *sonarExecuteScanReports) persist(stepConfig sonarExecuteScanOptions, gcpJsonKeyFilePath string, gcsBucketId string, gcsFolderPath string, gcsSubFolder string) { 58 if gcsBucketId == "" { 59 log.Entry().Info("persisting reports to GCS is disabled, because gcsBucketId is empty") 60 return 61 } 62 log.Entry().Info("Uploading reports to Google Cloud Storage...") 63 content := []gcs.ReportOutputParam{ 64 {FilePattern: "**/sonarscan.json", ParamRef: "", StepResultType: "sonarqube"}, 65 {FilePattern: "**/sonarscan-result.json", ParamRef: "", StepResultType: "sonarqube"}, 66 } 67 envVars := []gcs.EnvVar{ 68 {Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: gcpJsonKeyFilePath, Modified: false}, 69 } 70 gcsClient, err := gcs.NewClient(gcs.WithEnvVars(envVars)) 71 if err != nil { 72 log.Entry().Errorf("creation of GCS client failed: %v", err) 73 return 74 } 75 defer gcsClient.Close() 76 structVal := reflect.ValueOf(&stepConfig).Elem() 77 inputParameters := map[string]string{} 78 for i := 0; i < structVal.NumField(); i++ { 79 field := structVal.Type().Field(i) 80 if field.Type.String() == "string" { 81 paramName := strings.Split(field.Tag.Get("json"), ",") 82 paramValue, _ := structVal.Field(i).Interface().(string) 83 inputParameters[paramName[0]] = paramValue 84 } 85 } 86 if err := gcs.PersistReportsToGCS(gcsClient, content, inputParameters, gcsFolderPath, gcsBucketId, gcsSubFolder, doublestar.Glob, os.Stat); err != nil { 87 log.Entry().Errorf("failed to persist reports: %v", err) 88 } 89 } 90 91 type sonarExecuteScanInflux struct { 92 step_data struct { 93 fields struct { 94 sonar bool 95 } 96 tags struct { 97 } 98 } 99 sonarqube_data struct { 100 fields struct { 101 blocker_issues int 102 critical_issues int 103 major_issues int 104 minor_issues int 105 info_issues int 106 } 107 tags struct { 108 } 109 } 110 } 111 112 func (i *sonarExecuteScanInflux) persist(path, resourceName string) { 113 measurementContent := []struct { 114 measurement string 115 valType string 116 name string 117 value interface{} 118 }{ 119 {valType: config.InfluxField, measurement: "step_data", name: "sonar", value: i.step_data.fields.sonar}, 120 {valType: config.InfluxField, measurement: "sonarqube_data", name: "blocker_issues", value: i.sonarqube_data.fields.blocker_issues}, 121 {valType: config.InfluxField, measurement: "sonarqube_data", name: "critical_issues", value: i.sonarqube_data.fields.critical_issues}, 122 {valType: config.InfluxField, measurement: "sonarqube_data", name: "major_issues", value: i.sonarqube_data.fields.major_issues}, 123 {valType: config.InfluxField, measurement: "sonarqube_data", name: "minor_issues", value: i.sonarqube_data.fields.minor_issues}, 124 {valType: config.InfluxField, measurement: "sonarqube_data", name: "info_issues", value: i.sonarqube_data.fields.info_issues}, 125 } 126 127 errCount := 0 128 for _, metric := range measurementContent { 129 err := piperenv.SetResourceParameter(path, resourceName, filepath.Join(metric.measurement, fmt.Sprintf("%vs", metric.valType), metric.name), metric.value) 130 if err != nil { 131 log.Entry().WithError(err).Error("Error persisting influx environment.") 132 errCount++ 133 } 134 } 135 if errCount > 0 { 136 log.Entry().Error("failed to persist Influx environment") 137 } 138 } 139 140 // SonarExecuteScanCommand Executes the Sonar scanner 141 func SonarExecuteScanCommand() *cobra.Command { 142 const STEP_NAME = "sonarExecuteScan" 143 144 metadata := sonarExecuteScanMetadata() 145 var stepConfig sonarExecuteScanOptions 146 var startTime time.Time 147 var reports sonarExecuteScanReports 148 var influx sonarExecuteScanInflux 149 var logCollector *log.CollectorHook 150 var splunkClient *splunk.Splunk 151 telemetryClient := &telemetry.Telemetry{} 152 153 var createSonarExecuteScanCmd = &cobra.Command{ 154 Use: STEP_NAME, 155 Short: "Executes the Sonar scanner", 156 Long: `The step executes the [sonar-scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner) cli command to scan the defined sources and publish the results to a SonarQube instance.`, 157 PreRunE: func(cmd *cobra.Command, _ []string) error { 158 startTime = time.Now() 159 log.SetStepName(STEP_NAME) 160 log.SetVerbose(GeneralConfig.Verbose) 161 162 GeneralConfig.GitHubAccessTokens = ResolveAccessTokens(GeneralConfig.GitHubTokens) 163 164 path, _ := os.Getwd() 165 fatalHook := &log.FatalHook{CorrelationID: GeneralConfig.CorrelationID, Path: path} 166 log.RegisterHook(fatalHook) 167 168 err := PrepareConfig(cmd, &metadata, STEP_NAME, &stepConfig, config.OpenPiperFile) 169 if err != nil { 170 log.SetErrorCategory(log.ErrorConfiguration) 171 return err 172 } 173 log.RegisterSecret(stepConfig.Token) 174 log.RegisterSecret(stepConfig.GithubToken) 175 176 if len(GeneralConfig.HookConfig.SentryConfig.Dsn) > 0 { 177 sentryHook := log.NewSentryHook(GeneralConfig.HookConfig.SentryConfig.Dsn, GeneralConfig.CorrelationID) 178 log.RegisterHook(&sentryHook) 179 } 180 181 if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 { 182 splunkClient = &splunk.Splunk{} 183 logCollector = &log.CollectorHook{CorrelationID: GeneralConfig.CorrelationID} 184 log.RegisterHook(logCollector) 185 } 186 187 validation, err := validation.New(validation.WithJSONNamesForStructFields(), validation.WithPredefinedErrorMessages()) 188 if err != nil { 189 return err 190 } 191 if err = validation.ValidateStruct(stepConfig); err != nil { 192 log.SetErrorCategory(log.ErrorConfiguration) 193 return err 194 } 195 196 return nil 197 }, 198 Run: func(_ *cobra.Command, _ []string) { 199 stepTelemetryData := telemetry.CustomData{} 200 stepTelemetryData.ErrorCode = "1" 201 handler := func() { 202 reports.persist(stepConfig, GeneralConfig.GCPJsonKeyFilePath, GeneralConfig.GCSBucketId, GeneralConfig.GCSFolderPath, GeneralConfig.GCSSubFolder) 203 influx.persist(GeneralConfig.EnvRootPath, "influx") 204 config.RemoveVaultSecretFiles() 205 stepTelemetryData.Duration = fmt.Sprintf("%v", time.Since(startTime).Milliseconds()) 206 stepTelemetryData.ErrorCategory = log.GetErrorCategory().String() 207 stepTelemetryData.PiperCommitHash = GitCommit 208 telemetryClient.SetData(&stepTelemetryData) 209 telemetryClient.Send() 210 if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 { 211 splunkClient.Send(telemetryClient.GetData(), logCollector) 212 } 213 } 214 log.DeferExitHandler(handler) 215 defer handler() 216 telemetryClient.Initialize(GeneralConfig.NoTelemetry, STEP_NAME) 217 if len(GeneralConfig.HookConfig.SplunkConfig.Dsn) > 0 { 218 splunkClient.Initialize(GeneralConfig.CorrelationID, 219 GeneralConfig.HookConfig.SplunkConfig.Dsn, 220 GeneralConfig.HookConfig.SplunkConfig.Token, 221 GeneralConfig.HookConfig.SplunkConfig.Index, 222 GeneralConfig.HookConfig.SplunkConfig.SendLogs) 223 } 224 sonarExecuteScan(stepConfig, &stepTelemetryData, &influx) 225 stepTelemetryData.ErrorCode = "0" 226 log.Entry().Info("SUCCESS") 227 }, 228 } 229 230 addSonarExecuteScanFlags(createSonarExecuteScanCmd, &stepConfig) 231 return createSonarExecuteScanCmd 232 } 233 234 func addSonarExecuteScanFlags(cmd *cobra.Command, stepConfig *sonarExecuteScanOptions) { 235 cmd.Flags().StringVar(&stepConfig.Instance, "instance", os.Getenv("PIPER_instance"), "Jenkins only: The name of the SonarQube instance defined in the Jenkins settings. DEPRECATED: use serverUrl parameter instead") 236 cmd.Flags().StringVar(&stepConfig.ServerURL, "serverUrl", os.Getenv("PIPER_serverUrl"), "The URL to the Sonar backend.") 237 cmd.Flags().StringVar(&stepConfig.Token, "token", os.Getenv("PIPER_token"), "Token used to authenticate with the Sonar Server.") 238 cmd.Flags().StringVar(&stepConfig.Organization, "organization", os.Getenv("PIPER_organization"), "SonarCloud.io only: Organization that the project will be assigned to in SonarCloud.io.") 239 cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with custom certificates.") 240 cmd.Flags().StringVar(&stepConfig.SonarScannerDownloadURL, "sonarScannerDownloadUrl", `https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip`, "URL to the sonar-scanner-cli archive.") 241 cmd.Flags().StringVar(&stepConfig.VersioningModel, "versioningModel", `major`, "The versioning model used for the version when reporting the results for the project.") 242 cmd.Flags().StringVar(&stepConfig.Version, "version", os.Getenv("PIPER_version"), "The project version that is reported to SonarQube.") 243 cmd.Flags().StringVar(&stepConfig.CustomScanVersion, "customScanVersion", os.Getenv("PIPER_customScanVersion"), "A custom version used along with the uploaded scan results.") 244 cmd.Flags().StringVar(&stepConfig.ProjectKey, "projectKey", os.Getenv("PIPER_projectKey"), "The project key identifies the project in SonarQube.") 245 cmd.Flags().StringSliceVar(&stepConfig.CoverageExclusions, "coverageExclusions", []string{}, "A list of patterns that should be excluded from the coverage scan.") 246 cmd.Flags().BoolVar(&stepConfig.InferJavaBinaries, "inferJavaBinaries", false, "Find the location of generated Java class files in all modules and pass the option `sonar.java.binaries to the sonar tool.") 247 cmd.Flags().BoolVar(&stepConfig.InferJavaLibraries, "inferJavaLibraries", false, "If the parameter `m2Path` is configured for the step `mavenExecute` in the general section of the configuration, pass it as option `sonar.java.libraries` to the sonar tool.") 248 cmd.Flags().StringSliceVar(&stepConfig.Options, "options", []string{}, "A list of options which are passed to the sonar-scanner.") 249 cmd.Flags().StringVar(&stepConfig.BranchName, "branchName", os.Getenv("PIPER_branchName"), "Non-Pull-Request only: Name of the SonarQube branch that should be used to report findings to. Automatically inferred from environment variables on supported orchestrators if `inferBranchName` is set to true.") 250 cmd.Flags().BoolVar(&stepConfig.InferBranchName, "inferBranchName", false, "Whether to infer the `branchName` parameter automatically based on the orchestrator-specific environment variable in runs of the pipeline.") 251 cmd.Flags().StringVar(&stepConfig.ChangeID, "changeId", os.Getenv("PIPER_changeId"), "Pull-Request only: The id of the pull-request. Automatically inferred from environment variables on supported orchestrators.") 252 cmd.Flags().StringVar(&stepConfig.ChangeBranch, "changeBranch", os.Getenv("PIPER_changeBranch"), "Pull-Request only: The name of the pull-request branch. Automatically inferred from environment variables on supported orchestrators.") 253 cmd.Flags().StringVar(&stepConfig.ChangeTarget, "changeTarget", os.Getenv("PIPER_changeTarget"), "Pull-Request only: The name of the base branch. Automatically inferred from environment variables on supported orchestrators.") 254 cmd.Flags().StringVar(&stepConfig.PullRequestProvider, "pullRequestProvider", `GitHub`, "Pull-Request only: The scm provider.") 255 cmd.Flags().StringVar(&stepConfig.Owner, "owner", os.Getenv("PIPER_owner"), "Pull-Request only: The owner of the scm repository.") 256 cmd.Flags().StringVar(&stepConfig.Repository, "repository", os.Getenv("PIPER_repository"), "Pull-Request only: The scm repository.") 257 cmd.Flags().StringVar(&stepConfig.GithubToken, "githubToken", os.Getenv("PIPER_githubToken"), "Pull-Request only: Token for Github to set status on the Pull-Request.") 258 cmd.Flags().BoolVar(&stepConfig.DisableInlineComments, "disableInlineComments", false, "Pull-Request only: Disables the pull-request decoration with inline comments. DEPRECATED: only supported in SonarQube < 7.2") 259 cmd.Flags().BoolVar(&stepConfig.LegacyPRHandling, "legacyPRHandling", false, "Pull-Request only: Activates the pull-request handling using the [GitHub Plugin](https://docs.sonarqube.org/display/PLUG/GitHub+Plugin). DEPRECATED: only supported in SonarQube < 7.2") 260 cmd.Flags().StringVar(&stepConfig.GithubAPIURL, "githubApiUrl", `https://api.github.com`, "Pull-Request only: The URL to the Github API. See [GitHub plugin docs](https://docs.sonarqube.org/display/PLUG/GitHub+Plugin#GitHubPlugin-Usage) DEPRECATED: only supported in SonarQube < 7.2") 261 cmd.Flags().StringVar(&stepConfig.M2Path, "m2Path", os.Getenv("PIPER_m2Path"), "Path to the location of the local repository that should be used.") 262 263 } 264 265 // retrieve step metadata 266 func sonarExecuteScanMetadata() config.StepData { 267 var theMetaData = config.StepData{ 268 Metadata: config.StepMetadata{ 269 Name: "sonarExecuteScan", 270 Aliases: []config.Alias{}, 271 Description: "Executes the Sonar scanner", 272 }, 273 Spec: config.StepSpec{ 274 Inputs: config.StepInputs{ 275 Secrets: []config.StepSecrets{ 276 {Name: "sonarTokenCredentialsId", Description: "Jenkins 'Secret text' credentials ID containing the token used to authenticate with the Sonar Server.", Type: "jenkins"}, 277 {Name: "githubTokenCredentialsId", Description: "Jenkins 'Secret text' credentials ID containing the token used to authenticate with the Github Server.", Type: "jenkins"}, 278 }, 279 Parameters: []config.StepParameters{ 280 { 281 Name: "instance", 282 ResourceRef: []config.ResourceReference{}, 283 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 284 Type: "string", 285 Mandatory: false, 286 Aliases: []config.Alias{}, 287 Default: os.Getenv("PIPER_instance"), 288 }, 289 { 290 Name: "serverUrl", 291 ResourceRef: []config.ResourceReference{}, 292 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 293 Type: "string", 294 Mandatory: false, 295 Aliases: []config.Alias{{Name: "host"}, {Name: "sonarServerUrl"}}, 296 Default: os.Getenv("PIPER_serverUrl"), 297 }, 298 { 299 Name: "token", 300 ResourceRef: []config.ResourceReference{ 301 { 302 Name: "sonarVaultSecretName", 303 Type: "vaultSecret", 304 Default: "sonar", 305 }, 306 307 { 308 Name: "sonarTokenCredentialsId", 309 Type: "secret", 310 }, 311 }, 312 Scope: []string{"PARAMETERS"}, 313 Type: "string", 314 Mandatory: false, 315 Aliases: []config.Alias{{Name: "sonarToken"}}, 316 Default: os.Getenv("PIPER_token"), 317 }, 318 { 319 Name: "organization", 320 ResourceRef: []config.ResourceReference{}, 321 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 322 Type: "string", 323 Mandatory: false, 324 Aliases: []config.Alias{}, 325 Default: os.Getenv("PIPER_organization"), 326 }, 327 { 328 Name: "customTlsCertificateLinks", 329 ResourceRef: []config.ResourceReference{}, 330 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 331 Type: "[]string", 332 Mandatory: false, 333 Aliases: []config.Alias{}, 334 Default: []string{}, 335 }, 336 { 337 Name: "sonarScannerDownloadUrl", 338 ResourceRef: []config.ResourceReference{}, 339 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 340 Type: "string", 341 Mandatory: false, 342 Aliases: []config.Alias{}, 343 Default: `https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip`, 344 }, 345 { 346 Name: "versioningModel", 347 ResourceRef: []config.ResourceReference{}, 348 Scope: []string{"GENERAL", "STAGES", "STEPS", "PARAMETERS"}, 349 Type: "string", 350 Mandatory: false, 351 Aliases: []config.Alias{}, 352 Default: `major`, 353 }, 354 { 355 Name: "version", 356 ResourceRef: []config.ResourceReference{ 357 { 358 Name: "commonPipelineEnvironment", 359 Param: "artifactVersion", 360 }, 361 }, 362 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 363 Type: "string", 364 Mandatory: false, 365 Aliases: []config.Alias{{Name: "projectVersion", Deprecated: true}}, 366 Default: os.Getenv("PIPER_version"), 367 }, 368 { 369 Name: "customScanVersion", 370 ResourceRef: []config.ResourceReference{}, 371 Scope: []string{"GENERAL", "STAGES", "STEPS", "PARAMETERS"}, 372 Type: "string", 373 Mandatory: false, 374 Aliases: []config.Alias{}, 375 Default: os.Getenv("PIPER_customScanVersion"), 376 }, 377 { 378 Name: "projectKey", 379 ResourceRef: []config.ResourceReference{}, 380 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 381 Type: "string", 382 Mandatory: false, 383 Aliases: []config.Alias{}, 384 Default: os.Getenv("PIPER_projectKey"), 385 }, 386 { 387 Name: "coverageExclusions", 388 ResourceRef: []config.ResourceReference{}, 389 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 390 Type: "[]string", 391 Mandatory: false, 392 Aliases: []config.Alias{}, 393 Default: []string{}, 394 }, 395 { 396 Name: "inferJavaBinaries", 397 ResourceRef: []config.ResourceReference{}, 398 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 399 Type: "bool", 400 Mandatory: false, 401 Aliases: []config.Alias{}, 402 Default: false, 403 }, 404 { 405 Name: "inferJavaLibraries", 406 ResourceRef: []config.ResourceReference{}, 407 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 408 Type: "bool", 409 Mandatory: false, 410 Aliases: []config.Alias{}, 411 Default: false, 412 }, 413 { 414 Name: "options", 415 ResourceRef: []config.ResourceReference{}, 416 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 417 Type: "[]string", 418 Mandatory: false, 419 Aliases: []config.Alias{{Name: "sonarProperties", Deprecated: true}}, 420 Default: []string{}, 421 }, 422 { 423 Name: "branchName", 424 ResourceRef: []config.ResourceReference{}, 425 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 426 Type: "string", 427 Mandatory: false, 428 Aliases: []config.Alias{}, 429 Default: os.Getenv("PIPER_branchName"), 430 }, 431 { 432 Name: "inferBranchName", 433 ResourceRef: []config.ResourceReference{}, 434 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 435 Type: "bool", 436 Mandatory: false, 437 Aliases: []config.Alias{}, 438 Default: false, 439 }, 440 { 441 Name: "changeId", 442 ResourceRef: []config.ResourceReference{}, 443 Scope: []string{"PARAMETERS"}, 444 Type: "string", 445 Mandatory: false, 446 Aliases: []config.Alias{}, 447 Default: os.Getenv("PIPER_changeId"), 448 }, 449 { 450 Name: "changeBranch", 451 ResourceRef: []config.ResourceReference{}, 452 Scope: []string{"PARAMETERS"}, 453 Type: "string", 454 Mandatory: false, 455 Aliases: []config.Alias{}, 456 Default: os.Getenv("PIPER_changeBranch"), 457 }, 458 { 459 Name: "changeTarget", 460 ResourceRef: []config.ResourceReference{}, 461 Scope: []string{"PARAMETERS"}, 462 Type: "string", 463 Mandatory: false, 464 Aliases: []config.Alias{}, 465 Default: os.Getenv("PIPER_changeTarget"), 466 }, 467 { 468 Name: "pullRequestProvider", 469 ResourceRef: []config.ResourceReference{}, 470 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 471 Type: "string", 472 Mandatory: false, 473 Aliases: []config.Alias{}, 474 Default: `GitHub`, 475 }, 476 { 477 Name: "owner", 478 ResourceRef: []config.ResourceReference{ 479 { 480 Name: "commonPipelineEnvironment", 481 Param: "github/owner", 482 }, 483 }, 484 Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"}, 485 Type: "string", 486 Mandatory: false, 487 Aliases: []config.Alias{{Name: "githubOrg"}}, 488 Default: os.Getenv("PIPER_owner"), 489 }, 490 { 491 Name: "repository", 492 ResourceRef: []config.ResourceReference{ 493 { 494 Name: "commonPipelineEnvironment", 495 Param: "github/repository", 496 }, 497 }, 498 Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"}, 499 Type: "string", 500 Mandatory: false, 501 Aliases: []config.Alias{{Name: "githubRepo"}}, 502 Default: os.Getenv("PIPER_repository"), 503 }, 504 { 505 Name: "githubToken", 506 ResourceRef: []config.ResourceReference{ 507 { 508 Name: "githubTokenCredentialsId", 509 Type: "secret", 510 }, 511 512 { 513 Name: "githubVaultSecretName", 514 Type: "vaultSecret", 515 Default: "github", 516 }, 517 }, 518 Scope: []string{"PARAMETERS"}, 519 Type: "string", 520 Mandatory: false, 521 Aliases: []config.Alias{{Name: "access_token"}}, 522 Default: os.Getenv("PIPER_githubToken"), 523 }, 524 { 525 Name: "disableInlineComments", 526 ResourceRef: []config.ResourceReference{}, 527 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 528 Type: "bool", 529 Mandatory: false, 530 Aliases: []config.Alias{}, 531 Default: false, 532 }, 533 { 534 Name: "legacyPRHandling", 535 ResourceRef: []config.ResourceReference{}, 536 Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, 537 Type: "bool", 538 Mandatory: false, 539 Aliases: []config.Alias{}, 540 Default: false, 541 }, 542 { 543 Name: "githubApiUrl", 544 ResourceRef: []config.ResourceReference{}, 545 Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"}, 546 Type: "string", 547 Mandatory: false, 548 Aliases: []config.Alias{}, 549 Default: `https://api.github.com`, 550 }, 551 { 552 Name: "m2Path", 553 ResourceRef: []config.ResourceReference{}, 554 Scope: []string{"GENERAL", "STEPS", "STAGES", "PARAMETERS"}, 555 Type: "string", 556 Mandatory: false, 557 Aliases: []config.Alias{{Name: "maven/m2Path"}}, 558 Default: os.Getenv("PIPER_m2Path"), 559 }, 560 }, 561 }, 562 Containers: []config.Container{ 563 {Name: "sonar", Image: "sonarsource/sonar-scanner-cli:4.6"}, 564 }, 565 Outputs: config.StepOutputs{ 566 Resources: []config.StepResources{ 567 { 568 Name: "reports", 569 Type: "reports", 570 Parameters: []map[string]interface{}{ 571 {"filePattern": "**/sonarscan.json", "type": "sonarqube"}, 572 {"filePattern": "**/sonarscan-result.json", "type": "sonarqube"}, 573 }, 574 }, 575 { 576 Name: "influx", 577 Type: "influx", 578 Parameters: []map[string]interface{}{ 579 {"name": "step_data", "fields": []map[string]string{{"name": "sonar"}}}, 580 {"name": "sonarqube_data", "fields": []map[string]string{{"name": "blocker_issues"}, {"name": "critical_issues"}, {"name": "major_issues"}, {"name": "minor_issues"}, {"name": "info_issues"}}}, 581 }, 582 }, 583 }, 584 }, 585 }, 586 } 587 return theMetaData 588 }