-
Notifications
You must be signed in to change notification settings - Fork 0
How to Run Sonar Analyzer
Sonar-Analyzer is a tool that allows you to download source code from GitHub and analyze it with sonar-runner and store the result back to SonarQube. The tool allows you to define a specific frequency when new commits are requested from GitHub. If there are new commits then the tool analyses it automatically.
To run the tool you can provide the following arguments:
- --analyse analyzes the source downloaded
- --sonar-runner (optional, specifies the path to sonar-runner) If this argument is missing then the application searches for the sonar-runner executable upwards to the drive root.
- --token: the GitHub token (to see how to create a token click here
- --user: the GitHub user
- --password: the GitHub password
- --anonymous: (get the data from GitHub without authentication)
- --config: (optional) If this argument is missing then the application searches for configuration files in the /config subfolder which is relative to the executable. Configuration files must end in .json and must follow this Json-Schema.
- Following arguments are mutual exclusive: (token), (user/password), (anonymous). You have to specify at least one of the argument set specified in (...).
- If Two Factor Authentication is used then the token has to be provided rather than using user/password combination.
- For anonymous authentication the API-Limit is set to 60 request per hour. For any other authentication the limit is at 5000 request per hour.
A sample configuration file can be found here.
Following Json-Properties are required:
- GitHubRepositoryOwner: specifies the repository owner
- GitHubRepository: specifies the repository name
- RescanFrequency: specifies the time that has to pass until the next rescan for new commits is done.
- AnalyzationBehavior: specifies the behavior how of commits have to be downloaded. Possible values are:
- Tags: download only commits that are marked with a tag
- All: download all commits
- Newest: download only the newest existing commit.
- FirstAllThenNewest: download the first time all commits then after the RescanFequency time has passed only the newest commit.
You have to provide for each valid configuration file a corresponding .properties file that is used for sonar-runner to analyze the source. This .properties file must contain at least the sonar.projectKey and sonar.projectName property in order to get sunar-runner working. The file has to be named like the .json file.
If the config file is named TestConfig.json, then the corresponding file has to be named TestConfig.properties.