v0.4.7 introduces some new rules which now need to be handled.
Change-Id: I9c769bd819b787d817ef7708c312e9c637ee7dfc
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
local dest_dir
dest_dir="$(pwd)"
- pushd "$workspace"
+ pushd "$workspace" || exit
# First copy all archives provided by user if any
if [ "$(ls -A "$workspace/archives/")" ]; then
done
shopt -u globstar # Disable globstar once archives are copied
fi
- popd
+ popd || exit
}
deploy() {
local archive_pattern="${4:-}"
tmpdir=$(mktemp -d)
- pushd "$tmpdir"
+ pushd "$tmpdir" || exit
###################
# BEGIN ARCHIVING #
echo "Nothing to archive."
fi
- popd
+ popd || exit
rm -rf "$tmpdir"
}
local build_url="$3"
tmpdir=$(mktemp -d)
- pushd "$tmpdir"
+ pushd "$tmpdir" || exit
touch "_build-details.log"
{
curl --netrc --upload-file console-logs.zip \
"${nexus_url}/service/local/repositories/logs/content-compressed/${nexus_path}"
- popd
+ popd || exit
rm -rf "$tmpdir"
}
# https://issues.apache.org/jira/browse/MDEPLOY-193
local snapshot="false"
- while getopts s o; do
+ while getopts hs o; do
case "$o" in
h)
deploy_nexus_usage
exit 1
fi
- pushd "$deploy_dir"
+ pushd "$deploy_dir" || exit
if [ "$snapshot" == "true" ]; then
- file_list=($(find . -type f \
- ! -name _remote.repositories \
- ! -name resolver-status.properties \
- | cut -c 3-))
+ mapfile -t file_list < <(find . -type f \
+ ! -name _remote.repositories \
+ ! -name resolver-status.properties \
+ | cut -c 3-)
else
- file_list=($(find . -type f \
- ! -name "maven-metadata*" \
- ! -name _remote.repositories \
- ! -name resolver-status.properties \
- | cut -c 3-))
+ mapfile -t file_list < <(find . -type f \
+ ! -name "maven-metadata*" \
+ ! -name _remote.repositories \
+ ! -name resolver-status.properties \
+ | cut -c 3-)
fi
if hash parallel 2>/dev/null; then
export -f upload_to_nexus
upload_to_nexus "$nexus_repo_url" "$file"
done
fi
- popd
+ popd || exit
}
deploy_nexus_stage() {
# function loop_log_file takes care of the most common problems so far
function start_script {
- while getopts 'af:h' opt "$@"; do
+ while getopts af:h opt "$@"; do
case $opt in
- 'a')
- option=1
- ;;
- 'f')
- option=2
- FILES="$OPTARG"
- ;;
- 'h')
- option=3
- ;;
+ a)
+ option=1
+ ;;
+ f)
+ option=2
+ FILES="$OPTARG"
+ ;;
+ h)
+ option=3
+ ;;
+ *)
+ echo "ERROR: Unknown flag passed."
+ ;;
esac
done
test_gpg_key
set -e # Fail immediately if any if signing fails
- files_to_sign=($(find "$dir" -type f ! -name "*.asc" \
- ! -name "*.md5" \
- ! -name "*.sha1" \
- ! -name "_maven.repositories" \
- ! -name "_remote.repositories" \
- ! -name "*.lastUpdated" \
- ! -name "maven-metadata-local.xml" \
- ! -name "maven-metadata.xml"))
+ mapfile -t files_to_sign < <(find "$dir" -type f ! -name "*.asc" \
+ ! -name "*.md5" \
+ ! -name "*.sha1" \
+ ! -name "_maven.repositories" \
+ ! -name "_remote.repositories" \
+ ! -name "*.lastUpdated" \
+ ! -name "maven-metadata-local.xml" \
+ ! -name "maven-metadata.xml")
if [ "${#files_to_sign[@]}" -eq 0 ]; then
echo "ERROR: No files to sign. Quitting..."
# The resultant output of this command is stored in
# /tmp/gpg-signatures.XXXXXXXXXX unless the -d parameter is passed to
# override.
- while getopts d: o; do
+ while getopts d:h o; do
case "$o" in
h)
sign_nexus_usage
fi
echo "Removing files that do not need to be cloned..."
- remove_files=($(find . -type f -name "index.html" \
+ mapfile -t remove_files < <(find . -type f -name "index.html" \
-o -name "*.asc" \
-o -name "*.md5" \
-o -name "*.sha1" \
-o -name "_remote.repositories*" \
-o -name "maven-metadata-local.xml*" \
-o -name "maven-metadata.xml*" \
- -o -name "archetype-catalog.xml"))
+ -o -name "archetype-catalog.xml")
for f in "${remove_files[@]}"; do
rm "$f"
done
sign_dir "$sign_dir"
echo "Removing non-signature files..."
- remove_files=($(find . -type f -not -name '*.asc'))
+ mapfile -t remove_files < <(find . -type f -not -name '*.asc')
for f in "${remove_files[@]}"; do
rm "$f"
done