Skip to content

Commit e98d1d2

Browse files
Add CLI argument for project-name
1 parent c1b36ec commit e98d1d2

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/pysonar_scanner/configuration/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ def __parse_cli_args(cls) -> argparse.Namespace:
5454
type=str,
5555
help="Key of the project that usually corresponds to the project name in SonarQube",
5656
)
57+
parser.add_argument(
58+
"--sonar-project-name",
59+
"-Dsonar.projectName",
60+
type=str,
61+
help="Name of the project in SonarQube",
62+
)
5763

5864
parser.add_argument(
5965
"-v",

src/pysonar_scanner/configuration/properties.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,10 @@ class Property:
236236
default_value=None,
237237
cli_getter=lambda args: args.sonar_project_key
238238
),
239+
Property(
240+
name=SONAR_PROJECT_NAME,
241+
default_value=None,
242+
cli_getter=lambda args: args.sonar_project_name
243+
),
239244
]
240245
# fmt: on

tests/test_configuration_cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
SONAR_TOKEN,
5252
SONAR_USER_HOME,
5353
SONAR_VERBOSE,
54+
SONAR_PROJECT_NAME,
5455
)
5556

5657

@@ -116,6 +117,8 @@ def test_impossible_os_choice(self):
116117
"myToken",
117118
"--sonar-project-key",
118119
"myProjectKey",
120+
"--sonar-project-name",
121+
"myProjectName",
119122
"-v",
120123
"--sonar-host-url",
121124
"mySonarHostUrl",
@@ -171,6 +174,7 @@ def test_all_cli_args(self):
171174
expected_configuration = {
172175
SONAR_TOKEN: "myToken",
173176
SONAR_PROJECT_KEY: "myProjectKey",
177+
SONAR_PROJECT_NAME: "myProjectName",
174178
SONAR_VERBOSE: True,
175179
SONAR_HOST_URL: "mySonarHostUrl",
176180
SONAR_SCANNER_SONARCLOUD_URL: "mySonarScannerCloudUrl",

0 commit comments

Comments
 (0)