From: Thanh Ha Date: Wed, 7 Aug 2019 22:51:52 +0000 (-0400) Subject: Resolve ShellCheck in integration scripts X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=a67a867c7affe5e25546a415e1306b81c6860876;p=releng%2Fbuilder.git Resolve ShellCheck in integration scripts Change-Id: I53ee7dcb86e0711dacac98d126d86cc53614f759 Signed-off-by: Thanh Ha --- diff --git a/jjb/integration/copy-common-functions.sh b/jjb/integration/copy-common-functions.sh index c8835aad2..1ff42d091 100644 --- a/jjb/integration/copy-common-functions.sh +++ b/jjb/integration/copy-common-functions.sh @@ -14,7 +14,7 @@ if [ "${BASH_SOURCE[0]}" == "${0}" ]; then mapfile -t ips <<< "$(openstack stack show -f json -c outputs "$STACK_NAME" | jq -r '.outputs[] | select(.output_key | match("^vm_[0-9]+_ips$")) | .output_value | .[]')" for ip in "${ips[@]}"; do echo "Copying common-functions.sh to ${ip}:/tmp" - scp /tmp/common-functions.sh ${ip}:/tmp + scp /tmp/common-functions.sh "${ip}:/tmp" done exit 0 fi diff --git a/jjb/integration/integration-compare-distributions.sh b/jjb/integration/integration-compare-distributions.sh index 372001436..6e48b2d23 100644 --- a/jjb/integration/integration-compare-distributions.sh +++ b/jjb/integration/integration-compare-distributions.sh @@ -22,8 +22,9 @@ BUNDLE_VERSION=$(xpath pom.xml '/project/version/text()' 2> /dev/null) echo "Bundle version is ${BUNDLE_VERSION}" # Acquire the timestamp information from maven-metadata.xml NEXUSPATH="${NEXUSURL_PREFIX}/${ODL_NEXUS_REPO}/org/opendaylight/integration/${KARAF_ARTIFACT}" -wget ${NEXUSPATH}/${BUNDLE_VERSION}/maven-metadata.xml +wget "${NEXUSPATH}/${BUNDLE_VERSION}/maven-metadata.xml" +# shellcheck disable=SC2181 if [ $? -ne 0 ]; then echo "unable to find maven-metadata.xml. no need to continue..." exit 0 @@ -36,27 +37,27 @@ BUNDLEFOLDER="${KARAF_ARTIFACT}-${BUNDLE_VERSION}" BUNDLE="${KARAF_ARTIFACT}-${TIMESTAMP}.zip" ACTUAL_BUNDLE_URL="${NEXUSPATH}/${BUNDLE_VERSION}/${BUNDLE}" -wget --progress=dot:mega $ACTUAL_BUNDLE_URL +wget --progress=dot:mega "$ACTUAL_BUNDLE_URL" echo "Extracting the last distribution found on nexus..." -unzip -q $BUNDLE -mv $BUNDLEFOLDER /tmp/distro_old -rm $BUNDLE +unzip -q "$BUNDLE" +mv "$BUNDLEFOLDER" /tmp/distro_old +rm "$BUNDLE" echo "Extracting the distribution just created by this job..." -NEW_DISTRO="$(find $WORKSPACE -name "${KARAF_ARTIFACT}*.zip")" +NEW_DISTRO="$(find "$WORKSPACE" -name "${KARAF_ARTIFACT}*.zip")" NEW_DISTRO_BASENAME="$(basename "$NEW_DISTRO")" -cp $NEW_DISTRO /tmp/ +cp "$NEW_DISTRO" /tmp/ cd /tmp/ || exit -unzip $NEW_DISTRO_BASENAME -mv $BUNDLEFOLDER distro_new +unzip "$NEW_DISTRO_BASENAME" +mv "$BUNDLEFOLDER" distro_new git clone https://git.opendaylight.org/gerrit/integration/test.git cd test/tools/distchanges || exit -mkdir -p $WORKSPACE/archives +mkdir -p "$WORKSPACE"/archives # Full output of compare tool will be in temp file /tmp/dist_diff.txt # The file/report to be archived will only list the distribution in the comparison and the patches that # are different. -python distcompare.py -r ssh://jenkins-$SILO@git.opendaylight.org:29418 | tee /tmp/dist_diff.txt -echo -e "Patch differences listed are in comparison to:\n\t$ACTUAL_BUNDLE_URL\n\n" > $WORKSPACE/archives/distribution_differences.txt -sed -ne '/Patch differences/,$ p' /tmp/dist_diff.txt >> $WORKSPACE/archives/distribution_differences.txt +python distcompare.py -r "ssh://jenkins-$SILO@git.opendaylight.org:29418" | tee /tmp/dist_diff.txt +echo -e "Patch differences listed are in comparison to:\n\t$ACTUAL_BUNDLE_URL\n\n" > "$WORKSPACE"/archives/distribution_differences.txt +sed -ne '/Patch differences/,$ p' /tmp/dist_diff.txt >> "$WORKSPACE"/archives/distribution_differences.txt diff --git a/jjb/integration/integration-configure-clustering.sh b/jjb/integration/integration-configure-clustering.sh index 43df86444..33f7b5463 100644 --- a/jjb/integration/integration-configure-clustering.sh +++ b/jjb/integration/integration-configure-clustering.sh @@ -1,10 +1,11 @@ +#!/bin/bash #@IgnoreInspection BashAddShebang # Activate robotframework virtualenv # ${ROBOT_VENV} comes from the integration-install-robotframework.sh # script. -# shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091 -source ${ROBOT_VENV}/bin/activate -source /tmp/common-functions.sh ${BUNDLEFOLDER} +# shellcheck disable=SC1090,SC1091 +source "${ROBOT_VENV}/bin/activate" +source /tmp/common-functions.sh "${BUNDLEFOLDER}" echo "#################################################" echo "## Configure Cluster and Start ##" diff --git a/jjb/integration/integration-detect-variables.sh b/jjb/integration/integration-detect-variables.sh index 961df7bcb..f2acb4c6e 100644 --- a/jjb/integration/integration-detect-variables.sh +++ b/jjb/integration/integration-detect-variables.sh @@ -1,11 +1,11 @@ - +#!/bin/bash # TODO: Document the default values. NEXUSURL_PREFIX="${ODLNEXUSPROXY:-https://nexus.opendaylight.org}" ODL_NEXUS_REPO="${ODL_NEXUS_REPO:-content/repositories/opendaylight.snapshot}" GERRIT_PATH="${GERRIT_PATH:-git.opendaylight.org/gerrit}" DISTROBRANCH="${DISTROBRANCH:-$GERRIT_BRANCH}" -if [ ${BUNDLE_URL} == 'last' ]; then +if [ "${BUNDLE_URL}" == 'last' ]; then # Obtain current pom.xml of integration/distribution, correct branch. if [[ "$KARAF_ARTIFACT" == "opendaylight" ]]; then wget "http://${GERRIT_PATH}/gitweb?p=integration/distribution.git;a=blob_plain;f=opendaylight/pom.xml;hb=refs/heads/$DISTROBRANCH" -O "pom.xml" diff --git a/jjb/integration/integration-get-apex-addresses.sh b/jjb/integration/integration-get-apex-addresses.sh index 3f2dd8bc6..005df5541 100644 --- a/jjb/integration/integration-get-apex-addresses.sh +++ b/jjb/integration/integration-get-apex-addresses.sh @@ -23,6 +23,7 @@ OPENSTACK_COMPUTE_NODE_2_IP=$(python /tmp/opnfv_releng/jjb/cperf/parse-node-yaml OPENSTACK_CONTROL_NODE_1_IP=$ODL_SYSTEM_IP ODL_SYSTEM_1_IP=$ODL_SYSTEM_IP +# shellcheck disable=SC2129 echo "NUM_OPENSTACK_SYSTEM=$NUM_OPENSTACK_SYSTEM" >> slave_addresses.txt echo "NUM_ODL_SYSTEM=$NUM_ODL_SYSTEM" >> slave_addresses.txt echo "ODL_SYSTEM_IP=$ODL_SYSTEM_IP" >> slave_addresses.txt @@ -46,7 +47,7 @@ JOB_SUM=$(echo "$JOB_NAME" | sum | awk '{ print $1 }') VM_NAME="$JOB_SUM-$BUILD_NUMBER" SERVER_ID="$(openstack server show -f value -c id "$(hostname -s)")" NETWORK_ID="$(openstack network show -f value -c id "$SILO-$VM_NAME-APEX_192_network")" -openstack server add network $SERVER_ID $NETWORK_ID +openstack server add network "$SERVER_ID" "$NETWORK_ID" ETH1_MAC=$(ip address show eth1 | grep ether | awk -F' ' '{print $2}') ETH1_SCRIPT="/etc/sysconfig/network-scripts/ifcfg-eth1" sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 "$ETH1_SCRIPT" diff --git a/jjb/integration/integration-upload-distribution.sh b/jjb/integration/integration-upload-distribution.sh index 073db0ebd..354401b14 100644 --- a/jjb/integration/integration-upload-distribution.sh +++ b/jjb/integration/integration-upload-distribution.sh @@ -16,7 +16,7 @@ echo "Uploading distribution to Nexus..." -DrepositoryId=opendaylight-snapshot \ -Durl="$ODLNEXUSPROXY/content/repositories/opendaylight.snapshot/" \ -DgroupId="org.opendaylight.integration.${GERRIT_PROJECT//\//.}" \ - -DartifactId=${KARAF_ARTIFACT} \ + -DartifactId="${KARAF_ARTIFACT}" \ -Dversion="${BUNDLE_VERSION}" \ -Dpackaging=zip \ || true # Sandbox is not allowed to uplad to Nexus. diff --git a/jjb/integration/update-csit-tests.sh b/jjb/integration/update-csit-tests.sh index b6da8dcf4..92bfe1e45 100644 --- a/jjb/integration/update-csit-tests.sh +++ b/jjb/integration/update-csit-tests.sh @@ -13,10 +13,10 @@ echo "---> update-csit-tests.sh" jobs_file=$(mktemp) search_string="csit" -wget --quiet -O "$jobs_file" https://jenkins.opendaylight.org/$SILO/api/xml +wget --quiet -O "$jobs_file" "https://jenkins.opendaylight.org/$SILO/api/xml" # shellcheck disable=SC2207 jobs=($(xmlstarlet sel -t -m '//hudson/job' \ - -n -v 'name' "$jobs_file" | grep $search_string | grep $STREAM)) + -n -v 'name' "$jobs_file" | grep $search_string | grep "$STREAM")) # output as comma-separated list job_list="${WORKSPACE}/jjb/integration/csit-jobs-${STREAM}.lst"