@@ -51,7 +51,7 @@ validate_git_provider() {
51
51
if [ " $git_provider_val " == " GITLAB" ] || [ " $git_provider_val " == " GITHUB" ] || [ " $git_provider_val " == " BITBUCKET" ]; then
52
52
echo $git_provider_val
53
53
else
54
- echo " Invalid git provider value. Please enter either GITLAB or GITHUB or BIBUCKET ."
54
+ echo " Invalid git provider value. Please enter either GITLAB or GITHUB or BITBUCKET ."
55
55
exit 1
56
56
fi
57
57
}
@@ -102,6 +102,16 @@ validate_cr_event_type() {
102
102
fi
103
103
}
104
104
105
+ posting_to_pr=" True"
106
+ validate_posting_to_pr () {
107
+ local boolean_val=" $( echo " $1 " | awk ' {print tolower($0)}' ) "
108
+ if [ " $boolean_val " == " true" ]; then
109
+ posting_to_pr=" True"
110
+ elif [ " $boolean_val " == " false" ]; then
111
+ posting_to_pr=" False"
112
+ fi
113
+ }
114
+
105
115
# Function to validate a review_comments vallue i.e. 1 mapped to "FULLPOST" or 2 mapped to "INLINE"
106
116
validate_review_comments () {
107
117
local review_comments=" $1 "
@@ -156,6 +166,7 @@ display_usage() {
156
166
echo " Usage-2: $0 service start | restart <path-to-properties-file>"
157
167
echo " Usage-3: $0 service stop"
158
168
echo " Usage-4: $0 service status"
169
+ echo " Usage-5: $0 <path-to-properties-file> pr_url=<url-value>"
159
170
}
160
171
161
172
check_properties_file () {
247
258
properties_file=
248
259
action_directory=
249
260
force_mode=
261
+ pr_url_arg=
262
+
263
+ process_pr_url_or_action_dir_param () {
264
+ local param=" $1 "
265
+
266
+ if [[ " $param " == pr_url= * ]]; then
267
+ pr_url_arg=" ${param#* =} "
268
+ else
269
+ action_directory=$( check_action_directory " $param " )
270
+ if [ $? -ne 0 ]; then
271
+ echo " Action directory not found!"
272
+ exit 1
273
+ fi
274
+ fi
275
+ }
276
+
250
277
if [ " $# " -gt 1 ]; then
251
278
if [ " $1 " == " service" ]; then
252
279
case " $2 " in
@@ -319,12 +346,16 @@ if [ "$#" -gt 1 ]; then
319
346
320
347
# Note down the hidden parameter for action directory
321
348
if [ " $# " -eq 2 ]; then
322
- action_directory=$( check_action_directory " $2 " )
323
- if [ $? -ne 0 ]; then
324
- echo " Action directory not found!"
325
- exit 1
326
- fi
327
- # echo "Action Diretory: $action_directory"
349
+ # check if 2nd argument is like pr_url=<value> then extract value else check the action_directory
350
+ process_pr_url_or_action_dir_param " $2 "
351
+ fi
352
+
353
+ if [ " $# " -eq 3 ]; then
354
+ # check if 2nd argument is like pr_url=<value> then extract value else check the action_directory
355
+ process_pr_url_or_action_dir_param " $2 "
356
+
357
+ # check if 3rd argument is like pr_url=<value> then extract value else check the action_directory
358
+ process_pr_url_or_action_dir_param " $3 "
328
359
fi
329
360
fi
330
361
else
@@ -349,6 +380,11 @@ while IFS='=' read -r key value; do
349
380
fi
350
381
done < " $properties_file "
351
382
383
+ # Override pr_url if provided as an argument
384
+ if [ -n " $pr_url_arg " ]; then
385
+ props[" pr_url" ]=" $pr_url_arg "
386
+ fi
387
+
352
388
# Function to ask for missing parameters
353
389
ask_for_param () {
354
390
local param_name=$1
@@ -394,6 +430,7 @@ optional_params_cli=(
394
430
" code_context"
395
431
" nexus_url"
396
432
" cr_event_type"
433
+ " posting_to_pr"
397
434
)
398
435
399
436
# Parameters that are required/optional in mode server
488
525
for param in " ${optional_params[@]} " ; do
489
526
if [ " $param " == " dependency_check.snyk_auth_token" ] && [ " ${props["dependency_check"]} " == " True" ]; then
490
527
ask_for_param " $param " " False"
491
- elif [ " $param " != " dependency_check.snyk_auth_token" ] && [ " $param " != " env" ] && [ " $param " != " cli_path" ] && [ " $param " != " output_path" ] && [ " $param " != " static_analysis_tool" ] && [ " $param " != " git.domain" ] && [ " $param " != " review_scope" ] && [ " $param " != " exclude_branches" ] && [ " $param " != " nexus_url" ] && [ " $param " != " exclude_files" ] && [ " $param " != " exclude_draft_pr" ] && [ " $param " != " cr_event_type" ]; then
528
+ elif [ " $param " != " dependency_check.snyk_auth_token" ] && [ " $param " != " env" ] && [ " $param " != " cli_path" ] && [ " $param " != " output_path" ] && [ " $param " != " static_analysis_tool" ] && [ " $param " != " git.domain" ] && [ " $param " != " review_scope" ] && [ " $param " != " exclude_branches" ] && [ " $param " != " nexus_url" ] && [ " $param " != " exclude_files" ] && [ " $param " != " exclude_draft_pr" ] && [ " $param " != " cr_event_type" ] && [ " $param " != " posting_to_pr " ] ; then
492
529
ask_for_param " $param " " False"
493
530
fi
494
531
done
@@ -575,13 +612,16 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
575
612
nexus_url=$( echo " ${props[$param]} " | sed ' s/^[ \t]*//;s/[ \t]*$//' )
576
613
elif [ " $param " == " cr_event_type" ]; then
577
614
validate_cr_event_type " ${props[$param]} "
615
+ elif [ " $param " == " posting_to_pr" ]; then
616
+ validate_posting_to_pr " ${props[$param]} "
578
617
else
579
618
docker_cmd+=" --$param =${props[$param]} "
580
619
fi
581
620
582
621
fi
583
622
done
584
623
docker_cmd+=" --cr_event_type=${cr_event_type} "
624
+ docker_cmd+=" --posting_to_pr=${posting_to_pr} "
585
625
docker_cmd=$docker_init_cmd$docker_cmd
586
626
docker_cmd+=' ${docker_enc_params}'
587
627
0 commit comments