Updates scripts/shell/job/gp/team-pipeline-local.sh script
This commit is contained in:
@@ -165,18 +165,32 @@ sort_pom_paths_for_compilation_order() {
|
||||
printf "%s\n" "${sorted_pom_paths[@]}"
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
while true; do
|
||||
read -p '' yn
|
||||
case $yn in
|
||||
[Yy]* ) return 0;;
|
||||
[Nn]* ) return 1;;
|
||||
[Cc]* ) exit;;
|
||||
* ) echo "Please answer YES, NO, or CANCEL.";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
if [ -z "$file_paths_arg" ] \
|
||||
&& [ -z "$commit_hashes_arg" ] \
|
||||
&& [ -z "$commits_between_arg" ] \
|
||||
&& ! $use_git_status; then
|
||||
echo "Error: Either one of these arguments should be provided:"
|
||||
echo " Commit hashes (--commit-hashes or -c) or;"
|
||||
echo " Commits between (--commits-between or -cb) or;"
|
||||
echo " File paths (--file-paths or -f) or;"
|
||||
echo " Use Git Status (--use-git-status or -g)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -z "$repo_dir" ]; then
|
||||
if [ -z "$commit_hashes_arg" ] && [ -z "$commits_between_arg" ]; then
|
||||
if [ -z "$commit_hashes_arg" ] && [ -z "$commits_between_arg" ] && [ ! $use_git_status ]; then
|
||||
echo "Error: If you specify the Commit hashes (--commit-hashes or -c) and/or Commits between (--commits-between or -cb), the repository directory (--repo-dir or -r) is also required."
|
||||
exit 1
|
||||
fi
|
||||
@@ -212,10 +226,6 @@ if [ ! -z "$commit_hashes_arg" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
if $use_git_status; then
|
||||
target_paths+=(`git ls-files --modified`)
|
||||
fi
|
||||
|
||||
if [ ! -z "$commits_between_arg" ]; then
|
||||
commit_hashes=`git rev-list --ancestry-path "${commits_between_arg/","/".."}"`
|
||||
target_paths_arg=()
|
||||
@@ -233,8 +243,6 @@ if [ ! -z "$commits_between_arg" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
cd $cur
|
||||
|
||||
if [ ! -z "$file_paths_arg" ]; then
|
||||
file_paths=`convert_csv_to_array "$file_paths_arg"`
|
||||
|
||||
@@ -245,7 +253,14 @@ if [ ! -z "$file_paths_arg" ]; then
|
||||
target_paths+=("$f")
|
||||
fi
|
||||
|
||||
cd $repo_dir
|
||||
if $use_git_status; then
|
||||
target_paths+=(`git ls-files --modified`)
|
||||
|
||||
if [ ${#target_paths[@]} -eq 0 ]; then
|
||||
echo "Error: You specified \"--use-git-status\" but there wasn't any modified files to use."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
target_paths_uniq=$(for i in "${target_paths[@]}"; do echo $i; done | sort -u)
|
||||
|
||||
@@ -314,13 +329,19 @@ 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
|
||||
|
||||
# extra paths because "cpqd-application-renderer-api-*" was inside another non-sense path
|
||||
extra_paths_to_explode=(`find * -maxdepth 1 -type f -wholename "**/cpqd-application-admweb-web*.war"`)
|
||||
extra_paths_to_explode+=(`find * -type f -wholename "**/cpqd-application-admweb-web*.war/**/cpqd-*-api-*.jar"`)
|
||||
|
||||
if [ ! -z "$extra_paths_to_explode" ]; then
|
||||
$scripts_folder/explode-java-files.sh --files `join_by , ${extra_paths_to_explode}`
|
||||
fi
|
||||
|
||||
src_path_const='src/main/java/'
|
||||
|
||||
unsuccessful_copies=()
|
||||
|
||||
for f in ${dot_java_files[@]}; do
|
||||
printf "\n"
|
||||
|
||||
f_dirname=`dirname $f`
|
||||
f_basename=`basename $f`
|
||||
class_filename=`echo ${f_basename%".java"}.class`
|
||||
@@ -331,10 +352,43 @@ for f in ${dot_java_files[@]}; do
|
||||
middle_path_subst=`get_substring_before_string "$f_dirname" "$src_path_const"`
|
||||
class_file_path_in_target=`find $repo_dir -type f -wholename "**/${middle_path_subst}target/classes/$path_in_deployments/$class_filename"`
|
||||
|
||||
# echo "f: $f"
|
||||
# echo "f_dirname: $f_dirname"
|
||||
# echo "class_filename: $class_filename"
|
||||
# echo "path_in_deployments: ${path_in_deployments}"
|
||||
if [ -z "$class_file_paths_in_deployments" ]; then
|
||||
echo "comando: find $deployments_path -type f -wholename \"**/$path_in_deployments/$class_filename\""
|
||||
echo "[WARN] O arquivo \"$f_basename\" não foi encontrado em algum diretório do deployments. Talvez ele precise ser copiado manualmente?"
|
||||
|
||||
echo "[ASK] Se for um arquivo novo, você sabe de alguma classe vizinha dele?"
|
||||
|
||||
if confirm; then
|
||||
# etapas para ver se o script criará um arquivo placeholder para fazer a busca depois
|
||||
echo "Informe o nome do arquivo (ex.: \"FilterResult.java\" - sem aspas):"
|
||||
read neighbour_filename
|
||||
neighbour_class_filename=`echo ${neighbour_filename%".java"}.class` # TODO, fazer virar função
|
||||
neighbour_class_filename_in_deployments=`find $deployments_path -type f -wholename "**/$path_in_deployments/$neighbour_class_filename"` # pode dar mais de um resultado
|
||||
|
||||
if [ ! -z "$neighbour_class_filename_in_deployments" ]; then
|
||||
echo "O arquivo vizinho informado existe em deployments."
|
||||
echo "Caminho(s):"
|
||||
|
||||
for d in ${neighbour_class_filename_in_deployments[@]}; do
|
||||
echo " $d"
|
||||
done
|
||||
|
||||
echo "[ASK] Deseja copiar o arquivo original que não foi encontrado no(s) mesmo(s) diretório(s)?"
|
||||
if confirm; then
|
||||
for d in ${neighbour_class_filename_in_deployments[@]}; do
|
||||
touch "`dirname $d`/$class_filename"
|
||||
done
|
||||
else
|
||||
unsuccessful_copies+=($f_basename)
|
||||
echo "Pulando cópia no mesmo diretório do arquivo vizinho..."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
unsuccessful_copies+=($f_basename)
|
||||
echo "Pulando cópia..."
|
||||
echo "comando: find $repo_dir -type f -wholename \"**/${middle_path_subst}target/classes/$path_in_deployments/$class_filename\""
|
||||
fi
|
||||
fi
|
||||
|
||||
# for i in ${class_file_paths_in_deployments[@]}; do
|
||||
# echo "i: $i"
|
||||
@@ -349,16 +403,51 @@ for f in ${dot_java_files[@]}; do
|
||||
# printf "\n"
|
||||
|
||||
for p in ${class_file_paths_in_deployments[@]}; do
|
||||
if [ -z "$class_file_path_in_target" ]; then
|
||||
echo "[WARN] O arquivo \"$f_basename\" não foi encontrado em uma pasta \"target\" fixa (\"$middle_path_subst\") do repositório. Pulando cópia..."
|
||||
|
||||
echo "[ASK] Deseja tentar fazer uma busca mais abrangente?"
|
||||
if confirm; then
|
||||
new_class_file_path_in_target=`find $repo_dir -type f -wholename "**/target/classes/**/$class_filename"`
|
||||
|
||||
if [ ! -z "$new_class_file_path_in_target" ]; then
|
||||
echo "Foi encontrado um caminho válido, mais abrangente, para o arquivo."
|
||||
echo "Caminho(s):"
|
||||
echo " $new_class_file_path_in_target"
|
||||
|
||||
echo "[ASK] Deseja usar ele na cópia?"
|
||||
|
||||
if confirm; then
|
||||
# defino como essa variável direto porque as próximas iterações, que serão do mesmo arquivo, usarão o novo caminho
|
||||
class_file_path_in_target=$new_class_file_path_in_target
|
||||
else
|
||||
unsuccessful_copies+=($f_basename)
|
||||
continue
|
||||
fi
|
||||
else
|
||||
unsuccessful_copies+=($f_basename)
|
||||
echo "Não foi possível encontrar um caminho válido, mais abrangente, para o arquivo."
|
||||
echo "Pulando cópia..."
|
||||
continue
|
||||
fi
|
||||
else
|
||||
unsuccessful_copies+=($f_basename)
|
||||
continue
|
||||
fi
|
||||
|
||||
# echo "comando: find $repo_dir -type f -wholename \"**/${middle_path_subst}target/classes/$path_in_deployments/$class_filename\""
|
||||
# echo "f: $f"
|
||||
# echo "f_dirname: $f_dirname"
|
||||
# echo "f_basename: $f_basename"
|
||||
# echo "class_filename: $class_filename"
|
||||
# echo "path_in_deployments: ${path_in_deployments}"
|
||||
# echo "class_file_paths_in_deployments: ${class_file_paths_in_deployments}"
|
||||
fi
|
||||
|
||||
|
||||
cp_dest=`dirname $p`
|
||||
|
||||
printf "\n"
|
||||
|
||||
if [ -z "$class_file_path_in_target" ]; then
|
||||
unsuccessful_copies+=($f_basename)
|
||||
echo "[WARN] O arquivo \"$f_basename\" não foi encontrado em alguma pasta target do repositório. Pulando cópia..."
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "[INFO] Copiando arquivo:"
|
||||
echo " De: $class_file_path_in_target"
|
||||
echo " Para: $cp_dest"
|
||||
@@ -378,7 +467,7 @@ if [ ${#unsuccessful_copies[@]} -ne 0 ]; then
|
||||
unsuccessful_copies_uniq=$(for i in "${unsuccessful_copies[@]}"; do echo $i; done | sort -u)
|
||||
|
||||
printf "\n"
|
||||
echo "[WARN] Houveram arquivos que não foram encontrados em alguma pasta target do repositório."
|
||||
echo "[WARN] Houveram arquivos que não puderam ser atualizados. Consulte o log do script."
|
||||
|
||||
for i in ${unsuccessful_copies_uniq[@]}; do
|
||||
echo " Arquivo mal-sucedido: $i"
|
||||
|
||||
Reference in New Issue
Block a user