@@ -51,7 +51,7 @@ validate_git_provider() {
5151 if [ " $git_provider_val " == " GITLAB" ] || [ " $git_provider_val " == " GITHUB" ] || [ " $git_provider_val " == " BITBUCKET" ]; then
5252 echo $git_provider_val
5353 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 ."
5555 exit 1
5656 fi
5757}
@@ -102,6 +102,16 @@ validate_cr_event_type() {
102102 fi
103103}
104104
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+
105115# Function to validate a review_comments vallue i.e. 1 mapped to "FULLPOST" or 2 mapped to "INLINE"
106116validate_review_comments () {
107117 local review_comments=" $1 "
@@ -156,6 +166,7 @@ display_usage() {
156166 echo " Usage-2: $0 service start | restart <path-to-properties-file>"
157167 echo " Usage-3: $0 service stop"
158168 echo " Usage-4: $0 service status"
169+ echo " Usage-5: $0 <path-to-properties-file> pr_url=<url-value>"
159170}
160171
161172check_properties_file () {
247258properties_file=
248259action_directory=
249260force_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+
250277if [ " $# " -gt 1 ]; then
251278 if [ " $1 " == " service" ]; then
252279 case " $2 " in
@@ -319,12 +346,16 @@ if [ "$#" -gt 1 ]; then
319346
320347 # Note down the hidden parameter for action directory
321348 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 "
328359 fi
329360 fi
330361else
@@ -349,6 +380,11 @@ while IFS='=' read -r key value; do
349380 fi
350381done < " $properties_file "
351382
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+
352388# Function to ask for missing parameters
353389ask_for_param () {
354390 local param_name=$1
@@ -394,6 +430,7 @@ optional_params_cli=(
394430 " code_context"
395431 " nexus_url"
396432 " cr_event_type"
433+ " posting_to_pr"
397434)
398435
399436# Parameters that are required/optional in mode server
488525for param in " ${optional_params[@]} " ; do
489526 if [ " $param " == " dependency_check.snyk_auth_token" ] && [ " ${props["dependency_check"]} " == " True" ]; then
490527 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
492529 ask_for_param " $param " " False"
493530 fi
494531done
@@ -575,13 +612,16 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
575612 nexus_url=$( echo " ${props[$param]} " | sed ' s/^[ \t]*//;s/[ \t]*$//' )
576613 elif [ " $param " == " cr_event_type" ]; then
577614 validate_cr_event_type " ${props[$param]} "
615+ elif [ " $param " == " posting_to_pr" ]; then
616+ validate_posting_to_pr " ${props[$param]} "
578617 else
579618 docker_cmd+=" --$param =${props[$param]} "
580619 fi
581620
582621 fi
583622done
584623docker_cmd+=" --cr_event_type=${cr_event_type} "
624+ docker_cmd+=" --posting_to_pr=${posting_to_pr} "
585625docker_cmd=$docker_init_cmd$docker_cmd
586626docker_cmd+=' ${docker_enc_params}'
587627
0 commit comments