Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action][sonar] replace deprecated sonar.login parameter with sonar.token #21736

Merged
merged 2 commits into from Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions fastlane/lib/fastlane/actions/sonar.rb
Expand Up @@ -20,6 +20,7 @@ def self.run(params)
sonar_scanner_args << "-Dsonar.language=\"#{params[:project_language]}\"" if params[:project_language]
sonar_scanner_args << "-Dsonar.sourceEncoding=\"#{params[:source_encoding]}\"" if params[:source_encoding]
sonar_scanner_args << "-Dsonar.login=\"#{params[:sonar_login]}\"" if params[:sonar_login]
sonar_scanner_args << "-Dsonar.token=\"#{params[:sonar_token]}\"" if params[:sonar_token]
sonar_scanner_args << "-Dsonar.host.url=\"#{params[:sonar_url]}\"" if params[:sonar_url]
sonar_scanner_args << "-Dsonar.organization=\"#{params[:sonar_organization]}\"" if params[:sonar_organization]
sonar_scanner_args << "-Dsonar.branch.name=\"#{params[:branch_name]}\"" if params[:branch_name]
Expand Down Expand Up @@ -100,9 +101,17 @@ def self.available_options
optional: true),
FastlaneCore::ConfigItem.new(key: :sonar_login,
lacostej marked this conversation as resolved.
Show resolved Hide resolved
env_name: "FL_SONAR_LOGIN",
description: "Pass the Sonar Login token (e.g: xxxxxxprivate_token_XXXXbXX7e)",
description: "Pass the Sonar Login Token (e.g: xxxxxxprivate_token_XXXXbXX7e)",
deprecated: "Login and password were deprecated in favor of login token. See https://community.sonarsource.com/t/deprecating-sonar-login-and-sonar-password-in-favor-of-sonar-token/95829 for more details",
optional: true,
sensitive: true),
sensitive: true,
conflicting_options: [:sonar_token]),
FastlaneCore::ConfigItem.new(key: :sonar_token,
env_name: "FL_SONAR_TOKEN",
description: "Pass the Sonar Token (e.g: xxxxxxprivate_token_XXXXbXX7e)",
optional: true,
sensitive: true,
conflicting_options: [:sonar_login]),
FastlaneCore::ConfigItem.new(key: :sonar_url,
env_name: "FL_SONAR_URL",
description: "Pass the url of the Sonar server",
Expand Down Expand Up @@ -156,7 +165,7 @@ def self.example_code
project_name: "iOS - AwesomeApp",
sources_path: File.expand_path("../AwesomeApp"),
sonar_organization: "myOrg",
sonar_login: "123456abcdef",
sonar_token: "123456abcdef",
sonar_url: "https://sonarcloud.io"
)'
]
Expand Down
8 changes: 4 additions & 4 deletions fastlane/spec/actions_specs/sonar_spec.rb
Expand Up @@ -16,11 +16,11 @@

it "Should not print sonar command" do
allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(nil)
expected_command = "cd #{File.expand_path('.').shellescape} && sonar-scanner -Dsonar.login=\"asdf\""
expected_command = "cd #{File.expand_path('.').shellescape} && sonar-scanner -Dsonar.token=\"asdf\""
expect(Fastlane::Actions::SonarAction).to receive(:verify_sonar_scanner_binary).and_return(true)
expect(Fastlane::Actions).to receive(:sh_control_output).with(expected_command, print_command: false, print_command_output: true).and_call_original
Fastlane::FastFile.new.parse("lane :sonar_test do
sonar(sonar_login: 'asdf')
sonar(sonar_token: 'asdf')
end").runner.execute(:sonar_test)
end

Expand All @@ -38,7 +38,7 @@
exclusions: '/Sources/Excluded',
project_language: 'ruby',
source_encoding: 'utf-8',
sonar_login: 'sonar-login',
sonar_token: 'sonar-token',
sonar_url: 'http://www.sonarqube.com',
sonar_organization: 'org-key',
branch_name: 'branch-name',
Expand All @@ -57,7 +57,7 @@
-Dsonar.exclusions=\"/Sources/Excluded\"
-Dsonar.language=\"ruby\"
-Dsonar.sourceEncoding=\"utf-8\"
-Dsonar.login=\"sonar-login\"
-Dsonar.token=\"sonar-token\"
-Dsonar.host.url=\"http://www.sonarqube.com\"
-Dsonar.organization=\"org-key\"
-Dsonar.branch.name=\"branch-name\"
Expand Down