From 7898197ea5dd3dd5c14d4b2f4e0fb31349b38929 Mon Sep 17 00:00:00 2001 From: Matheus Albino Brunhara Date: Tue, 2 Apr 2024 09:41:53 -0300 Subject: [PATCH] Adjusting scripts/shell/job/gp files --- scripts/shell/job/gp/explode-java-files.sh | 17 +++++--- scripts/shell/job/gp/install-gp.sh | 30 +++++++------ .../gp/remove-all-dot-failed-files-in-pwd.sh | 3 ++ .../shell/job/gp/remove-all-folders-in-pwd.sh | 3 ++ ...tension.sh => revert-all-dot-old-files.sh} | 0 scripts/shell/job/gp/team-pipeline-local.sh | 43 ++++++++++++------- 6 files changed, 62 insertions(+), 34 deletions(-) create mode 100755 scripts/shell/job/gp/remove-all-dot-failed-files-in-pwd.sh create mode 100755 scripts/shell/job/gp/remove-all-folders-in-pwd.sh rename scripts/shell/job/gp/{remove-all-files-old-extension.sh => revert-all-dot-old-files.sh} (100%) diff --git a/scripts/shell/job/gp/explode-java-files.sh b/scripts/shell/job/gp/explode-java-files.sh index d9c8400..a33331a 100755 --- a/scripts/shell/job/gp/explode-java-files.sh +++ b/scripts/shell/job/gp/explode-java-files.sh @@ -51,16 +51,21 @@ for f in ${files[@]}; do file_without_old_suffix=${f%".old"} # "f" will have ".old" suffix + rm --recursive --force $file_without_old_suffix mv $f $file_without_old_suffix - zip $file_without_old_suffix $f - rm -f "$file_without_old_suffix.dodeploy" + rm "$file_without_old_suffix.dodeploy" + + rm --force "$file_without_old_suffix.isdeploying" + rm --force "$file_without_old_suffix.deployed" + rm --force "$file_without_old_suffix.failed" + rm --force cpqd-ds.xml.failed else mv $f $f.old unzip -d $f $f.old touch $f.dodeploy - fi - rm -f "$f.isdeploying" - rm -f "$f.deployed" - rm -f "$f.failed" + rm --force "$f.isdeploying" + rm --force "$f.deployed" + rm --force "$f.failed" + fi done diff --git a/scripts/shell/job/gp/install-gp.sh b/scripts/shell/job/gp/install-gp.sh index ec1e076..69249e2 100755 --- a/scripts/shell/job/gp/install-gp.sh +++ b/scripts/shell/job/gp/install-gp.sh @@ -21,6 +21,14 @@ while [ "$#" -gt 0 ]; do done root_dir=`pwd` + +if [ `basename $root_dir` != "$version" ]; then + mkdir --parents $version + cd $version + # sudo rm -rf * + root_dir=`pwd` +fi + scripts_folder=$HOME/repos/personal/personal-devboot/scripts/shell/job/gp if [ -z "$version" ]; then @@ -83,8 +91,6 @@ if $should_download; then done fi -find * -maxdepth 0 -type d -exec sudo rm -rf {} \; - # cpqd-msgs-map-1.8.7-RC02-bin.zip cpqd-msgs-package-1.8.7-RC02-bin.zip wildfly-15.0.0.Final.zip wildfly-8.2.1.zip cp /l/disk0/mbrunhara/gp/zips/* . @@ -92,10 +98,10 @@ cp /l/disk0/mbrunhara/gp/zips/* . mkdir -p cpqd-folders/audit cpqd-folders/exportacoes cpqd-folders/updater cpqd-folders/dataloader cpqd-folders/virtualdisk # unpacking files -unzip wildfly-8.2.1.zip +unzip -qq wildfly-8.2.1.zip find wildfly-8.2.1 -type f -name '*.sh' -exec chmod +x {} \; -unzip -d wildfly-configurator cpqd-etics-configurator-appserver-wildfly* +unzip -qq -d wildfly-configurator cpqd-etics-configurator-appserver-wildfly* chmod +x wildfly-configurator/configurator/bin/setup.sh wildfly-configurator/configurator/bin/setup.sh @@ -103,24 +109,22 @@ wildfly-configurator/configurator/bin/setup.sh # doing this again to add permissions for newly created files by configurator find wildfly-8.2.1 -type f -name '*.sh' -exec chmod +x {} \; -unzip -d server cpqd-etics-package-server* +unzip -qq -d server cpqd-etics-package-server* mv server/cpqd*/* server/ rmdir server/cpqd* -unzip -o -d server cpqd-dbmanager-etics-package* -unzip -o -d server cpqd-dbmanager-customer* -unzip -o -d server cpqd-etics-customer-*-package-server* +unzip -qq -o -d server cpqd-dbmanager-etics-package* +unzip -qq -o -d server cpqd-dbmanager-customer* +unzip -qq -o -d server cpqd-etics-customer-*-package-server* cd server/dbmanager -./dbmanager.sh & - -dbmanager_pid=`echo $!` -wait $dbmanager_pid +# removes '&' from the 'dbmanager.sh' script so this script can run things sequentially +# sed -i 's/org.eclipse.equinox.launcher.Main $ARGS &/org.eclipse.equinox.launcher.Main $ARGS/g' dbmanager.sh +./dbmanager.sh cd $root_dir/server/configurator/bin chmod +x setup.sh ./setup.sh -# TODO, depois daqui não executou deployments_folder=$root_dir/wildfly-8.2.1/ports-01/deployments diff --git a/scripts/shell/job/gp/remove-all-dot-failed-files-in-pwd.sh b/scripts/shell/job/gp/remove-all-dot-failed-files-in-pwd.sh new file mode 100755 index 0000000..f67b2fb --- /dev/null +++ b/scripts/shell/job/gp/remove-all-dot-failed-files-in-pwd.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find * -maxdepth 0 -type f -name '*.failed' -exec rm {} \; diff --git a/scripts/shell/job/gp/remove-all-folders-in-pwd.sh b/scripts/shell/job/gp/remove-all-folders-in-pwd.sh new file mode 100755 index 0000000..3b70450 --- /dev/null +++ b/scripts/shell/job/gp/remove-all-folders-in-pwd.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find * -maxdepth 0 -type d -exec sudo rm -rf {} \; diff --git a/scripts/shell/job/gp/remove-all-files-old-extension.sh b/scripts/shell/job/gp/revert-all-dot-old-files.sh similarity index 100% rename from scripts/shell/job/gp/remove-all-files-old-extension.sh rename to scripts/shell/job/gp/revert-all-dot-old-files.sh diff --git a/scripts/shell/job/gp/team-pipeline-local.sh b/scripts/shell/job/gp/team-pipeline-local.sh index 656a137..78272d1 100755 --- a/scripts/shell/job/gp/team-pipeline-local.sh +++ b/scripts/shell/job/gp/team-pipeline-local.sh @@ -1,5 +1,7 @@ #!/bin/bash +printf "\n" + show_help() { echo "Usage: $0 [--commit-hashes|-c commit hashes] [--deployments-path|-d deployments path]" echo "Options:" @@ -9,7 +11,7 @@ show_help() { echo " --deployments-path | -d (Required) Specify the Wildfly ports-XX/deployments path" echo " --file-paths | -f (Optional) Specify file paths to consider in the update, separation by comma (,)" echo " Specifying this will make the \"--commit-hashes\" parameter optional" - echo " --build | -b (Optional) If selected, the script will build the maven components in order to generate the target/ folder" + echo " --no-build | -b (Optional) If selected, the script will NOT build the maven components in order to generate the target/ folder" echo " --use-git-status | -g (Optional) Will add the files with differences from the \"git status\" command" } @@ -17,7 +19,7 @@ commit_hashes_arg='' repo_dir='' deployments_path='' file_paths_arg='' -build_maven=false +build_maven=true use_git_status=false while [ "$#" -gt 0 ]; do @@ -27,19 +29,12 @@ while [ "$#" -gt 0 ]; do --commit-hashes|-c) commit_hashes_arg="$2"; shift 2;; --deployments-path|-d) deployments_path="$2"; shift 2;; --file-paths|-f) file_paths_arg="$2"; shift 2;; - --build|-b) build_maven=true; shift 2;; + --no-build|-b) build_maven=false; shift 2;; --use-git-status|-g) use_git_status=true; shift 2;; *) shift ;; esac done -# echo "commit_hashes_arg: $commit_hashes_arg" -# echo "repo_dir: $repo_dir" -# echo "deployments_path: $deployments_path" -# echo "file_paths_arg: $file_paths_arg" -# echo "build_maven: $build_maven" -# echo "use_git_status: $use_git_status" - print_newline() { echo -e "" } @@ -85,7 +80,16 @@ arr_uniq() { } build_mvn() { - mvn clean install --file ./pom.xml --settings ~/.m2/settings.xml + echo "[INFO] Realizando build Maven no diretório \"`pwd`\"..." + + mvn --quiet clean install --file ./pom.xml --settings ~/.m2/settings.xml + + if [ $? -ne 0 ]; then + echo "[INFO] A build Maven resultou em erros. O script irá encerrar agora." + exit 1 + fi + + echo "[INFO] Build Maven concluída." } function join_by { @@ -182,7 +186,7 @@ for f in ${target_paths[@]}; do fi done -target_paths_uniq=($(printf "%s\n" `dirname ${target_paths[@]}` | sort -u)) +target_paths_uniq=`arr_uniq ${target_paths}` pom_paths=() @@ -191,7 +195,9 @@ for i in ${target_paths_uniq[@]}; do pom_paths+=("$res") done -for p in ${pom_paths[@]}; do +pom_paths_uniq=`arr_uniq ${pom_paths}` + +for p in ${pom_paths_uniq[@]}; do pom_dir=`dirname $p` cd $repo_dir/$pom_dir @@ -201,7 +207,7 @@ done non_root_deployments_files_to_explode=() non_root_deployments_files_to_explode_full_path=() -for p in ${pom_paths[@]}; do +for p in ${pom_paths_uniq[@]}; do pom_dir=$repo_dir/`dirname $p` if [ ! -d "$pom_dir/target" ]; then @@ -230,7 +236,7 @@ for f in ${non_root_deployments_files_to_explode[@]}; do non_root_deployments_files_to_explode_full_path+=("$file_path") done -if [ ! -z "$non_root_deployments_files_to_explode_full_path"]; then +if [ ! -z "$non_root_deployments_files_to_explode_full_path" ]; then $scripts_folder/explode-java-files.sh --files `join_by , ${non_root_deployments_files_to_explode_full_path}` # **/cpqd-geo-renderer-ejb, etc. fi @@ -248,6 +254,13 @@ for f in ${dot_java_files[@]}; do done for p in ${class_file_paths[@]}; do + printf "\n" + echo "[INFO] Copiando arquivo:" + echo " De: $p" + echo " Para: $class_path_in_target" + cp --force $class_path_in_target `dirname $p` + + echo "[INFO] Concluído." done done