Class: Fastlane::Actions::SonarAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::SonarAction
- Defined in:
- lib/fastlane/actions/sonar.rb
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, author, lane_context, method_missing, other_action, output, sample_return_value, sh, step_text
Class Method Details
.authors ⇒ Object
95 96 97 |
# File 'lib/fastlane/actions/sonar.rb', line 95 def self. ["c_gretzki"] end |
.available_options ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fastlane/actions/sonar.rb', line 51 def self. [ FastlaneCore::ConfigItem.new(key: :project_configuration_path, env_name: "FL_SONAR_RUNNER_PROPERTIES_PATH", description: "The path to your sonar project configuration file; defaults to `sonar-project.properties`", # default is enforced by sonar-scanner binary optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find file at path '#{value}'") unless value.nil? or File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :project_key, env_name: "FL_SONAR_RUNNER_PROJECT_KEY", description: "The key sonar uses to identify the project, e.g. `name.gretzki.awesomeApp`. Must either be specified here or inside the sonar project configuration file", optional: true), FastlaneCore::ConfigItem.new(key: :project_name, env_name: "FL_SONAR_RUNNER_PROJECT_NAME", description: "The name of the project that gets displayed on the sonar report page. Must either be specified here or inside the sonar project configuration file", optional: true), FastlaneCore::ConfigItem.new(key: :project_version, env_name: "FL_SONAR_RUNNER_PROJECT_VERSION", description: "The project's version that gets displayed on the sonar report page. Must either be specified here or inside the sonar project configuration file", optional: true), FastlaneCore::ConfigItem.new(key: :sources_path, env_name: "FL_SONAR_RUNNER_SOURCES_PATH", description: "Comma-separated paths to directories containing source files. Must either be specified here or inside the sonar project configuration file", optional: true), FastlaneCore::ConfigItem.new(key: :project_language, env_name: "FL_SONAR_RUNNER_PROJECT_LANGUAGE", description: "Language key, e.g. objc", optional: true), FastlaneCore::ConfigItem.new(key: :source_encoding, env_name: "FL_SONAR_RUNNER_SOURCE_ENCODING", description: "Used encoding of source files, e.g., UTF-8", optional: true), FastlaneCore::ConfigItem.new(key: :sonar_runner_args, env_name: "FL_SONAR_RUNNER_ARGS", description: "Pass additional arguments to sonar-scanner. Be sure to provide the arguments with a leading `-D` e.g. FL_SONAR_RUNNER_ARGS=\"-Dsonar.verbose=true\"", optional: true) ] end |
.category ⇒ Object
114 115 116 |
# File 'lib/fastlane/actions/sonar.rb', line 114 def self.category :testing end |
.description ⇒ Object
40 41 42 |
# File 'lib/fastlane/actions/sonar.rb', line 40 def self.description "Invokes sonar-scanner to programmatically run SonarQube analysis" end |
.details ⇒ Object
44 45 46 47 48 49 |
# File 'lib/fastlane/actions/sonar.rb', line 44 def self.details [ "See http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner for details.", "It can process unit test results if formatted as junit report as shown in [xctest](#xctest) action. It can also integrate coverage reports in Cobertura format, which can be transformed into by [slather](#slather) action." ].join("\n") end |
.example_code ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/fastlane/actions/sonar.rb', line 103 def self.example_code [ 'sonar( project_key: "name.gretzki.awesomeApp", project_version: "1.0", project_name: "iOS - AwesomeApp", sources_path: File.expand_path("../AwesomeApp") )' ] end |
.is_supported?(platform) ⇒ Boolean
99 100 101 |
# File 'lib/fastlane/actions/sonar.rb', line 99 def self.is_supported?(platform) true end |
.return_value ⇒ Object
91 92 93 |
# File 'lib/fastlane/actions/sonar.rb', line 91 def self.return_value "The exit code of the sonar-scanner binary" end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fastlane/actions/sonar.rb', line 4 def self.run(params) verify_sonar_scanner_binary command_prefix = [ 'cd', File.('.').shellescape, '&&' ].join(' ') sonar_scanner_args = [] sonar_scanner_args << "-Dproject.settings=\"#{params[:project_configuration_path]}\"" if params[:project_configuration_path] sonar_scanner_args << "-Dsonar.projectKey=\"#{params[:project_key]}\"" if params[:project_key] sonar_scanner_args << "-Dsonar.projectName=\"#{params[:project_name]}\"" if params[:project_name] sonar_scanner_args << "-Dsonar.projectVersion=\"#{params[:project_version]}\"" if params[:project_version] sonar_scanner_args << "-Dsonar.sources=\"#{params[:sources_path]}\"" if params[:sources_path] 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 << params[:sonar_runner_args] if params[:sonar_runner_args] command = [ command_prefix, 'sonar-scanner', sonar_scanner_args ].join(' ') Action.sh command end |
.verify_sonar_scanner_binary ⇒ Object
32 33 34 |
# File 'lib/fastlane/actions/sonar.rb', line 32 def self.verify_sonar_scanner_binary UI.user_error!("You have to install sonar-scanner using `brew install sonar-runner`") unless `which sonar-scanner`.to_s.length > 0 end |