SonarQube
This step allows you to analyse your code quality with the SonarQube CLI. Whichever workflow you are doing your code analysis after, please run the SonarQube step after that step is completed.
Prerequisites
The workflow steps that need to be executed before running the SonarQube workflow step, along with their respective reasons, are listed in the table below.
Prerequisite Workflow Step | Description |
---|---|
Git Clone | If you intend to retrieve the SonarQube Scanner parameters from the sonar-project.properties file in your repository, it's essential to employ the Git Clone step before the SonarQube step. After the Git Clone step is completed, it generates the AC_REPOSITORY_DIR variable, which is used as input for the SonarQube step. |
Input Variables
You can find all the parameters required for this step in the table below, with their descriptions in detail.
Please note that SonarQube is a commercial code quality analysis tool. The parameters required for the scanner to work should be used as Enviroment Variables as they may create security vulnerabilities. You can obtain these parameters by contacting your DevOps team.
Variable Name | Description | Status |
---|---|---|
$AC_SONAR_VERSION | You can change the SonarQube CLI version as you wish with the version parameter. The default will be the latest. For more information about the SonarQube CLI version, please check out this Github releases page. | Required |
$AC_SONAR_PARAMETERS | Scanner parameters are written in Java property format. You have extra parameters to be able to run Sonar Scanner; you can specify them directly here. If there is a sonar-project.properties file in the main directory of your repository, its contents will be used instead of the properties entered here. If this input variable is not defined and the mentioned file does not exist in your repository, then the SonarQube step will not work. | Optional |
$AC_SONAR_EXTRA_PARAMETERS | Extra command line parameters. Enter -X for debug mode. | Optional |
Including Tests
You can also include your unit/UI test results in the SonarQube analysis.
If you want to include your test results in the SonarQube analysis, always run the SonarQube step after the test step.
iOS Tests
SonarQube accepts XML
format files to analyse test results. In order to analyse your test results, do not forget to convert the test results to XML
format by running the Convert Xcresult to HTML/XML step after the Xcodebuild for Unit and UI testing step.
Android Tests
If you intend to send the test result file obtained from the Android unit test output to SonarQube, it is necessary to execute the Android Unit Tests step before the SonarQube step.
Ensure that the test result path provided to SonarQube as a property matches the test result path generated by the Android Unit Tests step, and direct the output to that location.
To access the source code of this component, please use the following link: