@@ -122,6 +122,22 @@ function ValidateCrEventType {
122
122
}
123
123
}
124
124
125
+ $postingToPr = " True"
126
+ function ValidatePostingToPr {
127
+ param ($boolean_val )
128
+ # Convert the input to title case (first letter uppercase, rest lowercase)
129
+ $boolean_val = $boolean_val.Substring (0 , 1 ).ToUpper() + $boolean_val.Substring (1 ).ToLower()
130
+
131
+ # Check if the converted value is either "True" or "False"
132
+ if ($boolean_val -ne " True" -and $boolean_val -ne " False" ) {
133
+ return $postingToPr
134
+ }
135
+
136
+ # Return the properly cased boolean value
137
+ return $boolean_val
138
+
139
+ }
140
+
125
141
# Function to display URL using IP address and port
126
142
# Run docker ps -l command and store the output
127
143
function Display-DockerUrl {
@@ -156,6 +172,7 @@ function Display-Usage {
156
172
Write-Host " Usage-2: $PSCommandPrefix service start | restart <path-to-properties-file>"
157
173
Write-Host " Usage-3: $PSCommandPrefix service stop"
158
174
Write-Host " Usage-4: $PSCommandPrefix service status"
175
+ Write-Host " Usage-5: $PSCommandPrefix <path-to-properties-file> pr_url=<url-value>"
159
176
}
160
177
161
178
function Check-PropertyFile {
@@ -257,6 +274,18 @@ if ($args.Count -lt 1) {
257
274
$properties_file = $null
258
275
$action_directory = $null
259
276
$force_mode = $null
277
+ $pr_url_arg = $null
278
+
279
+ function Process-PrUrlOrActionDirParam {
280
+ param ($func_local_arg )
281
+
282
+ if ($func_local_arg -like " pr_url=*" ) {
283
+ $pr_url_arg = $arg -replace " pr_url=" , " "
284
+ } else {
285
+ $action_directory = Check- ActionDirectory $func_local_arg
286
+ }
287
+ }
288
+
260
289
if ($args.Count -gt 1 ) {
261
290
if ($args [0 ] -eq " service" ) {
262
291
switch ($args [1 ]) {
@@ -311,7 +340,15 @@ if ($args.Count -gt 1) {
311
340
312
341
# Note down the hidden parameter for action directory
313
342
if ($args.Count -eq 2 ) {
314
- $action_directory = Check- ActionDirectory $args [1 ]
343
+ # check if 2nd argument is like pr_url=<value> then extract value else check the action_directory
344
+ Process - PrUrlOrActionDirParam $args [1 ]
345
+ }
346
+
347
+ if ($args.Count -eq 3 ) {
348
+ # check if 2nd argument is like pr_url=<value> then extract value else check the action_directory
349
+ Process - PrUrlOrActionDirParam $args [1 ]
350
+ # check if 3rd argument is like pr_url=<value> then extract value else check the action_directory
351
+ Process - PrUrlOrActionDirParam $args [2 ]
315
352
}
316
353
}
317
354
}
@@ -334,6 +371,11 @@ Get-Content $properties_file | ForEach-Object {
334
371
}
335
372
}
336
373
374
+ # Override pr_url if provided as an argument
375
+ if ($pr_url_arg ) {
376
+ $props [" pr_url" ] = $pr_url_arg
377
+ }
378
+
337
379
# Function to ask for missing parameters
338
380
function Ask-For-Param {
339
381
param ($param_name , $exit_on_empty )
@@ -377,6 +419,7 @@ $optional_params_cli = @(
377
419
" git.domain"
378
420
" code_context"
379
421
" cr_event_type"
422
+ " posting_to_pr"
380
423
)
381
424
382
425
# Parameters that are required/optional in mode server
@@ -473,7 +516,7 @@ foreach ($param in $required_params) {
473
516
foreach ($param in $optional_params ) {
474
517
if ($param -eq " dependency_check.snyk_auth_token" -and $props [" dependency_check" ] -eq " True" ) {
475
518
Ask- For- Param $param $false
476
- } elseif ($param -ne " dependency_check.snyk_auth_token" -and $param -ne " env" -and $param -ne " cli_path" -and $param -ne " output_path" -and $param -ne " static_analysis_tool" -and $param -ne " git.domain" -and $param -ne " review_scope" -and $param -ne " exclude_branches" -and $param -ne " exclude_files" -and $param -ne " exclude_draft_pr" -and $param -ne " cr_event_type" ) {
519
+ } elseif ($param -ne " dependency_check.snyk_auth_token" -and $param -ne " env" -and $param -ne " cli_path" -and $param -ne " output_path" -and $param -ne " static_analysis_tool" -and $param -ne " git.domain" -and $param -ne " review_scope" -and $param -ne " exclude_branches" -and $param -ne " exclude_files" -and $param -ne " exclude_draft_pr" -and $param -ne " cr_event_type" -and $param -ne " posting_to_pr " ) {
477
520
Ask- For- Param $param $false
478
521
}
479
522
}
@@ -540,12 +583,16 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
540
583
$docker_cmd += " --$param =$review_comments "
541
584
} elseif ($param -eq " cr_event_type" ) {
542
585
$crEventType = ValidateCrEventType $props [$param ]
543
- } else {
586
+ } elseif ($param -eq " posting_to_pr" ) {
587
+ $postingToPr = ValidatePostingToPr $props [$param ]
588
+ }
589
+ else {
544
590
$docker_cmd += " --$param =$ ( $props [$param ]) "
545
591
}
546
592
}
547
593
}
548
594
$docker_cmd += " --cr_event_type=$crEventType "
595
+ $docker_cmd += " --posting_to_pr=$postingToPr "
549
596
$docker_cmd = $docker_init_cmd + $docker_cmd
550
597
551
598
function Encrypt-GitSecret {
0 commit comments