diff --git a/fastlane/lib/fastlane/actions/sonar.rb b/fastlane/lib/fastlane/actions/sonar.rb index 5fe49b8c236..fdf8e7cc1ed 100644 --- a/fastlane/lib/fastlane/actions/sonar.rb +++ b/fastlane/lib/fastlane/actions/sonar.rb @@ -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] @@ -100,9 +101,17 @@ def self.available_options optional: true), FastlaneCore::ConfigItem.new(key: :sonar_login, 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", @@ -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" )' ] diff --git a/fastlane/spec/actions_specs/sonar_spec.rb b/fastlane/spec/actions_specs/sonar_spec.rb index 729596d9dbb..7b158cc42a8 100644 --- a/fastlane/spec/actions_specs/sonar_spec.rb +++ b/fastlane/spec/actions_specs/sonar_spec.rb @@ -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 @@ -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', @@ -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\"