mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +02:00
refactor(sonar): align serverUrl with other steps (#2090)
Co-authored-by: Daniel Kurzynski <daniel.kurzynski@sap.com>
This commit is contained in:
co-authored by
Daniel Kurzynski
parent
265541354d
commit
5eb4c9de29
@@ -86,8 +86,8 @@ func sonarExecuteScan(config sonarExecuteScanOptions, _ *telemetry.CustomData, i
|
||||
}
|
||||
|
||||
func runSonar(config sonarExecuteScanOptions, client piperhttp.Downloader, runner command.ExecRunner) error {
|
||||
if len(config.Host) > 0 {
|
||||
sonar.addEnvironment("SONAR_HOST_URL=" + config.Host)
|
||||
if len(config.ServerURL) > 0 {
|
||||
sonar.addEnvironment("SONAR_HOST_URL=" + config.ServerURL)
|
||||
}
|
||||
if len(config.Token) > 0 {
|
||||
sonar.addEnvironment("SONAR_TOKEN=" + config.Token)
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
type sonarExecuteScanOptions struct {
|
||||
Instance string `json:"instance,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
ServerURL string `json:"serverUrl,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
Organization string `json:"organization,omitempty"`
|
||||
CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"`
|
||||
@@ -136,8 +136,8 @@ func SonarExecuteScanCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
func addSonarExecuteScanFlags(cmd *cobra.Command, stepConfig *sonarExecuteScanOptions) {
|
||||
cmd.Flags().StringVar(&stepConfig.Instance, "instance", `SonarCloud`, "Jenkins only: The name of the SonarQube instance defined in the Jenkins settings. DEPRECATED: use host parameter instead")
|
||||
cmd.Flags().StringVar(&stepConfig.Host, "host", os.Getenv("PIPER_host"), "The URL to the Sonar backend.")
|
||||
cmd.Flags().StringVar(&stepConfig.Instance, "instance", `SonarCloud`, "Jenkins only: The name of the SonarQube instance defined in the Jenkins settings. DEPRECATED: use serverUrl parameter instead")
|
||||
cmd.Flags().StringVar(&stepConfig.ServerURL, "serverUrl", os.Getenv("PIPER_serverUrl"), "The URL to the Sonar backend.")
|
||||
cmd.Flags().StringVar(&stepConfig.Token, "token", os.Getenv("PIPER_token"), "Token used to authenticate with the Sonar Server.")
|
||||
cmd.Flags().StringVar(&stepConfig.Organization, "organization", os.Getenv("PIPER_organization"), "SonarCloud.io only: Organization that the project will be assigned to in SonarCloud.io.")
|
||||
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.")
|
||||
@@ -183,12 +183,12 @@ func sonarExecuteScanMetadata() config.StepData {
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "host",
|
||||
Name: "serverUrl",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "sonarServerUrl"}},
|
||||
Aliases: []config.Alias{{Name: "host"}, {Name: "sonarServerUrl"}},
|
||||
},
|
||||
{
|
||||
Name: "token",
|
||||
|
||||
@@ -114,7 +114,7 @@ func TestRunSonar(t *testing.T) {
|
||||
options := sonarExecuteScanOptions{
|
||||
CustomTLSCertificateLinks: []string{},
|
||||
Token: "secret-ABC",
|
||||
Host: "https://sonar.sap.com",
|
||||
ServerURL: "https://sonar.sap.com",
|
||||
Organization: "SAP",
|
||||
ProjectVersion: "1.2.3",
|
||||
}
|
||||
|
||||
@@ -18,21 +18,22 @@ spec:
|
||||
- name: instance
|
||||
type: string
|
||||
description: "Jenkins only: The name of the SonarQube instance defined in the Jenkins settings.
|
||||
DEPRECATED: use host parameter instead"
|
||||
DEPRECATED: use serverUrl parameter instead"
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
default: "SonarCloud"
|
||||
- name: host
|
||||
- name: serverUrl
|
||||
aliases:
|
||||
- name: host
|
||||
- name: sonarServerUrl
|
||||
type: string
|
||||
description: "The URL to the Sonar backend."
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
aliases:
|
||||
- name: sonarServerUrl
|
||||
- name: token
|
||||
type: string
|
||||
description: "Token used to authenticate with the Sonar Server."
|
||||
|
||||
Reference in New Issue
Block a user