From 9362211ab08c0e99348b0adc3f1a790896459ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Tue, 5 Dec 2023 17:16:58 +0100 Subject: [PATCH] Improve build.sh script Apply suggestions from ShellCheck --- scripts/build.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index aab72e00c1485..55d9f96c1e838 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -71,15 +71,15 @@ fi [ -z "$OUTPUT" ] && OUTPUT=artifacts echo "Creating output directory $OUTPUT/maven/org/opensearch if it doesn't already exist" -mkdir -p $OUTPUT/maven/org/opensearch +mkdir -p "$OUTPUT/maven/org/opensearch" # Build project and publish to maven local. echo "Building and publishing OpenSearch project to Maven Local" -./gradlew publishToMavenLocal -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER +./gradlew publishToMavenLocal -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER" # Publish to existing test repo, using this to stage release versions of the artifacts that can be released from the same build. echo "Publishing OpenSearch to Test Repository" -./gradlew publishNebulaPublicationToTestRepository -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER +./gradlew publishNebulaPublicationToTestRepository -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER" # Copy maven publications to be promoted echo "Copying Maven publications to $OUTPUT/maven/org" @@ -89,7 +89,7 @@ cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org # see https://github.com/opensearch-project/OpenSearch/blob/main/settings.gradle#L34 for other distribution targets [ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}') -[ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m` +[ -z "$ARCHITECTURE" ] && ARCHITECTURE=$(uname -m) [ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar" case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in @@ -157,13 +157,13 @@ esac echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE" -./gradlew :distribution:$TYPE:$TARGET:assemble -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER +./gradlew ":distribution:$TYPE:$TARGET:assemble" -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier="$QUALIFIER" # Copy artifact to dist folder in bundle build output echo "Copying artifact to ${OUTPUT}/dist" -[[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT" -ARTIFACT_BUILD_NAME=`ls distribution/$TYPE/$TARGET/build/distributions/ | grep "wazuh-indexer-min.*$SUFFIX.$EXT"` +# [[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT" +ARTIFACT_BUILD_NAME=$(ls "distribution/$TYPE/$TARGET/build/distributions/" | grep "wazuh-indexer-min.*$SUFFIX.$EXT") # [WAZUH] Used by the GH workflow to upload the artifact echo "$ARTIFACT_BUILD_NAME" > "$OUTPUT/artifact_name.txt" mkdir -p "${OUTPUT}/dist" -cp distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME "${OUTPUT}"/dist/$ARTIFACT_BUILD_NAME +cp "distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME" "${OUTPUT}/dist/$ARTIFACT_BUILD_NAME"