Skip to content

Commit 5aacd2c

Browse files
authored
SCANPY-167 add sonar.organization property (#188)
1 parent 4af7770 commit 5aacd2c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/pysonar_scanner/configuration/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ def __parse_cli_args(cls) -> tuple[argparse.Namespace, list[str]]:
110110
choices=["us"],
111111
help="The region to contact, only for SonarQube Cloud",
112112
)
113+
parser.add_argument(
114+
"--sonar-organization",
115+
"-Dsonar.organization",
116+
type=str,
117+
help="The key of the organization to which the project belongs",
118+
)
113119
parser.add_argument(
114120
"--sonar-user-home", "-Dsonar.userHome", type=str, help="Base sonar directory, ~/.sonar by default"
115121
)

src/pysonar_scanner/configuration/properties.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
SONAR_SCANNER_SONARCLOUD_URL: Key = "sonar.scanner.sonarcloudUrl"
2929
SONAR_SCANNER_API_BASE_URL: Key = "sonar.scanner.apiBaseUrl"
3030
SONAR_REGION: Key = "sonar.region"
31+
SONAR_ORGANIZATION: Key = "sonar.organization"
3132
SONAR_SCANNER_APP: Key = "sonar.scanner.app"
3233
SONAR_SCANNER_APP_VERSION: Key = "sonar.scanner.appVersion"
3334
SONAR_SCANNER_BOOTSTRAP_START_TIME: Key = "sonar.scanner.bootstrapStartTime"
@@ -178,6 +179,11 @@ def env_variable_name(self) -> str:
178179
default_value=None,
179180
cli_getter=lambda args: args.sonar_region
180181
),
182+
Property(
183+
name=SONAR_ORGANIZATION,
184+
default_value=None,
185+
cli_getter=lambda args: args.sonar_organization
186+
),
181187
Property(
182188
name=SONAR_SCANNER_SONARCLOUD_URL,
183189
default_value=None,

tests/unit/test_configuration_cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from pysonar_scanner.configuration.configuration_loader import CliConfigurationLoader
2626
from pysonar_scanner.configuration.properties import (
2727
SONAR_HOST_URL,
28+
SONAR_ORGANIZATION,
2829
SONAR_PYTHON_BANDIT_REPORT_PATHS,
2930
SONAR_PYTHON_FLAKE8_REPORT_PATHS,
3031
SONAR_PYTHON_MYPY_REPORT_PATHS,
@@ -126,6 +127,7 @@
126127
SONAR_SCANNER_JAVA_OPTS: "mySonarScannerJavaOpts",
127128
SONAR_SCANNER_METADATA_FILEPATH: "myMetadataFilepath",
128129
SONAR_REGION: "us",
130+
SONAR_ORGANIZATION: "mySonarOrganization",
129131
SONAR_USER_HOME: "mySonarUserHome",
130132
SONAR_FILESIZE_LIMIT: 1000,
131133
SONAR_CPD_PYTHON_MINIMUM_TOKENS: 15,
@@ -277,6 +279,8 @@ def test_impossible_os_choice(self):
277279
"mySonarHostUrl",
278280
"--sonar-region",
279281
"us",
282+
"--sonar-organization",
283+
"mySonarOrganization",
280284
"--sonar-user-home",
281285
"mySonarUserHome",
282286
"--sonar-scanner-cloud-url",
@@ -424,6 +428,7 @@ def test_all_cli_args(self):
424428
"-Dsonar.scanner.javaOpts=mySonarScannerJavaOpts",
425429
"-Dsonar.scanner.metadataFilepath=myMetadataFilepath",
426430
"-Dsonar.region=us",
431+
"-Dsonar.organization=mySonarOrganization",
427432
"-Dsonar.userHome=mySonarUserHome",
428433
"-Dsonar.projectBaseDir=mySonarProjectBaseDir",
429434
"-Dsonar.filesize.limit=1000",

0 commit comments

Comments
 (0)