@@ -93,6 +93,15 @@ validate_env() {
93
93
fi
94
94
}
95
95
96
+ cr_event_type=" automated"
97
+ validate_cr_event_type () {
98
+ local cr_event_type_val=" $1 "
99
+ if [ " $cr_event_type_val " == " manual" ]; then
100
+ cr_event_type=$cr_event_type_val
101
+ echo
102
+ fi
103
+ }
104
+
96
105
# Function to validate a review_comments vallue i.e. 1 mapped to "FULLPOST" or 2 mapped to "INLINE"
97
106
validate_review_comments () {
98
107
local review_comments=" $1 "
@@ -373,6 +382,8 @@ optional_params_cli=(
373
382
" static_analysis_tool"
374
383
" review_scope"
375
384
" exclude_branches"
385
+ " exclude_files"
386
+ " exclude_draft_pr"
376
387
" dependency_check"
377
388
" dependency_check.snyk_auth_token"
378
389
" cra_version"
@@ -381,6 +392,8 @@ optional_params_cli=(
381
392
" output_path"
382
393
" git.domain"
383
394
" code_context"
395
+ " nexus_url"
396
+ " cr_event_type"
384
397
)
385
398
386
399
# Parameters that are required/optional in mode server
@@ -398,6 +411,8 @@ optional_params_server=(
398
411
" static_analysis_tool"
399
412
" review_scope"
400
413
" exclude_branches"
414
+ " exclude_files"
415
+ " exclude_draft_pr"
401
416
" dependency_check"
402
417
" dependency_check.snyk_auth_token"
403
418
" server_port"
@@ -406,6 +421,8 @@ optional_params_server=(
406
421
" cli_path"
407
422
" git.domain"
408
423
" code_context"
424
+ " nexus_url"
425
+ " cr_event_type"
409
426
)
410
427
411
428
bee_params=(
@@ -425,6 +442,7 @@ cra_version="latest"
425
442
426
443
# Docker pull command
427
444
docker_pull=' docker pull bitoai/cra:${cra_version}'
445
+ nexus_url=
428
446
429
447
# Construct the docker run command
430
448
docker_init_cmd=' docker run --rm -it'
@@ -457,7 +475,9 @@ echo ""
457
475
# echo Optional Parameters: "${optional_params[@]}"
458
476
459
477
# Append Docker Image and Tag Placeholder
460
- docker_cmd+=' bitoai/cra:${cra_version}'
478
+ docker_repo=" bitoai/cra"
479
+ docker_cmd+=' ${docker_repo}:${cra_version}'
480
+
461
481
462
482
# Ask for required parameters if they are not set
463
483
for param in " ${required_params[@]} " ; do
468
488
for param in " ${optional_params[@]} " ; do
469
489
if [ " $param " == " dependency_check.snyk_auth_token" ] && [ " ${props["dependency_check"]} " == " True" ]; then
470
490
ask_for_param " $param " " False"
471
- 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" ]; then
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
472
492
ask_for_param " $param " " False"
473
493
fi
474
494
done
@@ -504,7 +524,11 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
504
524
scopes=$( echo ${props[$param]} | sed ' s/, */,/g' )
505
525
docker_cmd+=" --review_scope='[$scopes ]'"
506
526
elif [ " $param " == " exclude_branches" ]; then
507
- docker_cmd+=" --exclude_branches=${props[$param]} "
527
+ docker_cmd+=" --exclude_branches='${props[$param]} '"
528
+ elif [ " $param " == " exclude_files" ]; then
529
+ docker_cmd+=" --exclude_files='${props[$param]} '"
530
+ elif [ " $param " == " exclude_draft_pr" ]; then
531
+ docker_cmd+=" --exclude_draft_pr=${props[$param]} "
508
532
elif [ " $param " == " dependency_check" ]; then
509
533
# validate the dependency check boolean value
510
534
props[$param ]=$( validate_boolean " ${props[$param]} " )
@@ -547,12 +571,17 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
547
571
echo " Invalid value provided for review_comments. Exiting."
548
572
exit 1
549
573
fi
574
+ elif [ " $param " == " nexus_url" ]; then
575
+ nexus_url=$( echo " ${props[$param]} " | sed ' s/^[ \t]*//;s/[ \t]*$//' )
576
+ elif [ " $param " == " cr_event_type" ]; then
577
+ validate_cr_event_type " ${props[$param]} "
550
578
else
551
579
docker_cmd+=" --$param =${props[$param]} "
552
580
fi
553
581
554
582
fi
555
583
done
584
+ docker_cmd+=" --cr_event_type=${cr_event_type} "
556
585
557
586
docker_cmd=$docker_init_cmd$docker_cmd
558
587
param_bito_access_key=" bito_cli.bito.access_key"
573
602
echo " Running command: $( eval echo $docker_pull ) "
574
603
eval " $docker_pull "
575
604
605
+
606
+ if [ " $? " == 0 ] ; then
607
+ echo " Docker image pulled successfully."
608
+ else
609
+ if [[ -n " $nexus_url " ]]; then
610
+ nexus_pull=' docker pull ${nexus_url}/cra:${cra_version}'
611
+ echo " Running command: $( eval echo $nexus_pull ) "
612
+ eval " $nexus_pull "
613
+ if [ " $? " == 0 ]; then
614
+ docker_repo=' ${nexus_url}/cra'
615
+ docker_repo=$( eval echo " $docker_repo " )
616
+ echo " Successfully pulled docker image from Nexus."
617
+ else
618
+ echo " Failed to pull docker image from Nexus."
619
+ fi
620
+ fi
621
+ fi
622
+
623
+
576
624
if [ " $? " == 0 ]; then
577
- echo " Running command: $docker_cmd "
625
+ echo " Running command: $( eval echo $ docker_cmd) "
578
626
eval " $docker_cmd "
579
627
580
628
if [ " $? " == 0 ] && [ " $mode " == " server" ]; then
0 commit comments