Skip to content

Commit af4cad6

Browse files
SCANPY-156 Expand documentation for the pysonar-scanner
1 parent af66d93 commit af4cad6

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

README.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# pysonar
2-
A wrapper around SonarScanner CLI, available on PyPI.
3-
4-
# Disclaimer
5-
6-
This project is currently in beta and APIs are subject to change.
7-
These changes include configuration parameter names.
2+
A Python scanner for SonarQube, available on PyPI.
83

94
# Requirements
105

11-
- SonarQube v9.9 or higher
6+
- SonarQube v10.6 or above
127
- Python 3.8 or above
138

149
# Installation
@@ -28,25 +23,28 @@ It assumes a running SonarQube server or a project configured on SonarCloud.
2823
In order for the analysis to run, analysis properties need to be defined.
2924
There are multiple ways of providing these properties, described below in descending order of priority:
3025

31-
* Through CLI arguments to the `pysonar` command
32-
* Under the `[tool.sonar]` key of the `pyproject.toml` file
33-
* Through common properties extracted from the `pyproject.toml`
34-
* In a dedicated `sonar-project.properties` file
35-
* Through environment variables
26+
1. Through CLI arguments to the `pysonar` command
27+
2. Environment variables for individual properties (e.g. `SONAR_TOKEN`, `SONAR_VERBOSE`, `SONAR_HOST_URL`, ...)
28+
3. Generic environment variable `SONAR_SCANNER_JSON_PARAMS`
29+
4. Under the `[tool.sonar]` key of the `pyproject.toml` file
30+
5. In a dedicated `sonar-project.properties` file
31+
6. Through common properties extracted from the `pyproject.toml`
3632

3733
### Through CLI arguments
3834

3935
Analysis properties can be provided as CLI arguments to the `pysonar` command.
40-
They follow the same convention as when running the SonarScanner CLI directly
41-
(see [documentation](https://docs.sonarsource.com/sonarqube/9.9/analyzing-source-code/scanners/sonarscanner/#running-from-zip-file)).
36+
They can be provided in a similar way as when running the SonarScanner CLI directly
37+
(see [documentation](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/sonarscanner/#running-from-zip-file)).
4238
This means that analysis properties provided that way should be prepended with `-D`, for instance:
4339

4440
```
4541
$ pysonar -Dsonar.login=myAuthenticationToken
4642
```
4743

48-
You can use all the argument allowed by __SonarScanner__.
49-
For more information on __SonarScanner__ please refer to the [SonarScanner documentation](https://docs.sonarsource.com/sonarqube/9.9/analyzing-source-code/scanners/sonarscanner/)
44+
You can use all the arguments allowed by __SonarScanner__.
45+
For more information on __SonarScanner__ please refer to the [SonarScanner documentation](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/analysis-parameters/).
46+
47+
Additionally, some common properties can be provided using
5048

5149
### With a pyproject.toml file
5250

@@ -75,32 +73,31 @@ The configuration parameters can be found in the [SonarQube documentation](https
7573
In the `pyproject.toml` file the prefix `sonar.` for parameter keys should be omitted.
7674
For example, `sonar.scm.provider` in the documentation will become `scm.provider` in the `pyproject.toml` file.
7775

78-
By default, the scanner will expect the `pyproject.toml` file to be present in the current directory.
79-
However, its path can be provided manually through the `toml.path` ([SCANPY-40](https://sonarsource.atlassian.net/jira/software/c/projects/PYSCAN/issues/PYSCAN-40)) CLI argument as well as through the `sonar.projectHome` argument. For instance:
76+
By default, the scanner will expect the `pyproject.toml` file to be present in the current directory. However, its path can be provided manually through the `toml-path` CLI argument as well as through the `sonar.projectBaseDir` argument. For instance:
8077

8178
```
82-
pysonar --toml.path "path/to/pyproject.toml"
79+
pysonar --toml-path "path/to/pyproject.toml"
8380
```
8481

8582
Or:
8683

8784
```
88-
pysonar --sonar-project-home "path/to/projectHome"
85+
pysonar --sonar-project-base-dir "path/to/projectBaseDir"
8986
```
9087

88+
Or:
9189

92-
### Through project properties extracted from the `pyproject.toml`
93-
94-
When a `pyproject.toml` file is available, it is possible to set the `-read-project-config` flag
95-
to allow the scanner to deduce analysis properties from the project configuration.
90+
```
91+
pysonar --sonar-projectBaseDir "path/to/projectBaseDir"
92+
```
9693

97-
This is currently supported only for projects using `poetry`.
94+
### Through project properties extracted from the `pyproject.toml`
9895

99-
The Sonar scanner will then use the project name and version defined through Poetry, they won't have to be duplicated under a dedicated `tool.sonar` section.
96+
When a `pyproject.toml` file is available, the scanner can deduce analysis properties from the project configuration. This is currently supported only for projects using `poetry`.
10097

10198
### With a sonar-project.properties file
10299

103-
Exactly like [__SonarScanner__](https://docs.sonarsource.com/sonarqube/9.9/analyzing-source-code/scanners/sonarscanner/),
100+
Exactly like [__SonarScanner__](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/sonarscanner/),
104101
the analysis can also be configured with a `sonar-project.properties` file:
105102

106103
```
@@ -130,7 +127,7 @@ $ export SONAR_HOST_URL="http://localhost:9000"
130127
$ pysonar
131128
```
132129

133-
See the __SonarScanner__ [documentation](https://docs.sonarsource.com/sonarqube/9.9/analyzing-source-code/scanners/sonarscanner/) for more information.
130+
See the __SonarScanner__ [documentation](https://docs.sonarsource.com/sonarqube-server/2025.1/setup-and-upgrade/environment-variables/) for more information.
134131

135132
# Installation from testPyPI
136133

0 commit comments

Comments
 (0)