Resolve ShellCheck 0.4.7 issues 63/66963/3
authorThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 9 Jan 2018 03:09:09 +0000 (22:09 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 9 Jan 2018 03:30:11 +0000 (22:30 -0500)
Disable ShellCheck in integration as there are too many issues for
now that need to be resolved to work in SC 0.4.7. Also disable
shellcheck in global-jjb since this is an external project.

Change-Id: Ie449aeb708f0532626858168e2bfb606ce19066e
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
15 files changed:
.coafile
jjb/autorelease/autorelease-get-integration-test-variables.sh
jjb/autorelease/notify-build-failure.sh
jjb/autorelease/prepare-release.sh
jjb/autorelease/update-validate-autorelease-projects.sh
jjb/check-poms.sh
jjb/generate-csit-status-report.sh
jjb/opendaylight-infra-check-image-protection.sh
jjb/opendaylight-infra-copy-ssh-keys.sh
jjb/opendaylight-infra-update-image-list.sh
jjb/packaging/test-rpm-deps.sh
packer/provision/baseline.sh
packer/provision/devstack-pre-pip.sh
packer/provision/mininet-ovs-2.6.sh
packer/provision/mininet.sh

index 77775285f89363253ee6b199df26eddff0347d8f..60e83070f29ef42c5050e595d732c8608e4a3afa 100644 (file)
--- a/.coafile
+++ b/.coafile
@@ -30,6 +30,8 @@ bears = ShellCheckBear,
 files = **.sh
 ignore = .git/**,
     .tox/**,
+    jjb/global-jjb/**,
+    jjb/integration/**,
     jenkins-scripts/*-local-env.sh
 shell = bash
 indent_size = 4
index 8c4dc15e85f7743742c8548538ddb0468bdcdacd..e7e347f47d00b9c4dce52f7e52557f9e6f8d1591 100644 (file)
@@ -14,9 +14,9 @@
 # in cases where an internal ci system is using multiple NEXUS systems one for artifacts and another for staging,
 # we can override using ODLNEXUS_STAGING_URL to route the staging build to the 2nd server.
 # (most CI setups where a single Nexus server is used, ODLNEXUS_STAGING_URL should be left unset)
-NEXUS_STAGING_URL=${ODLNEXUS_STAGING_URL:-$ODLNEXUSPROXY}
+NEXUS_STAGING_URL="${ODLNEXUS_STAGING_URL:-$ODLNEXUSPROXY}"
 
-NEXUSURL=${NEXUS_STAGING_URL}/content/repositories/
+NEXUSURL="${NEXUS_STAGING_URL}/content/repositories/"
 VERSION=$(grep -m2 '<version>' "${WORKSPACE}/integration/distribution/${KARAF_ARTIFACT}/pom.xml" | tail -n1 | awk -F'[<|>]' '/version/ { printf $3 }')
 echo "VERSION: ${VERSION}"
 STAGING_REPO_ID=$(grep "Created staging repository with ID" "$WORKSPACE/deploy-staged-repository.log" | cut -d '"' -f2)
index 090e808039b1213b3c39127328813fc179737234..5128c97bbe3a68138838833f8432367a6ffe2203 100644 (file)
@@ -69,6 +69,7 @@ if [ ! -z "$ARTIFACT_ID" ]; then
               --else -o ""\
               "$p" 2>/dev/null)
         if [ ! -z "${GROUP}" ]; then
+            # shellcheck disable=SC2207
             grouplist+=($(echo "${GROUP}" | awk -F'.' '{ print $3 }'))
         fi
     done < <(find . -name "pom.xml")
index 51248b15e3f104bf30c48644ad272e3ecd0d5d8c..ca3174cb56044c0237d47977ca1670cfc703e96e 100644 (file)
@@ -53,7 +53,7 @@ git commit -am "Release $RELEASE_TAG"
 
 modules=$(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' pom.xml)
 for module in $modules; do
-    pushd "$module"
+    pushd "$module" || exit
     # TODO: Remove once stable/nitrogen is no longer supported.
     if [ "$GERRIT_BRANCH" == "stable/nitrogen" ] && [ "$module" == "yangtools" ]; then
         git format-patch --stdout "origin/v1.2.x" > "$PATCH_DIR/${module//\//-}.patch"
@@ -61,7 +61,7 @@ for module in $modules; do
         git format-patch --stdout "origin/$GERRIT_BRANCH" > "$PATCH_DIR/${module//\//-}.patch"
     fi
     git bundle create "$PATCH_DIR/${module//\//-}.bundle" "origin/master..HEAD"
-    popd
+    popd || exit
 done
 
 tar cvzf "$WORKSPACE/archives/patches.tar.gz" -C "$WORKSPACE/archives" patches
index e277a2a790883dbba700a51faf6e960a2cd8c63c..7fea2910e7cfda0aabb796482601531c6cfd2d95 100644 (file)
@@ -20,6 +20,8 @@ if ! grep "$BRANCH" /tmp/ar-branches.json; then
 fi
 
 wget -nv -O /tmp/pom.xml "https://git.opendaylight.org/gerrit/gitweb?p=releng/autorelease.git;a=blob_plain;f=pom.xml;hb=$GERRIT_BRANCH"
+# Allow word splitting as we only expect modules to appear
+# shellcheck disable=2207
 modules=($(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' /tmp/pom.xml))
 
 cat > "$YAML_FILE" << EOF
index 7ba7f699061112b35b7970067e4fa5f0ab3fb3b1..a23ca9ba958b517202e7b4568680dfe8c8d16c7a 100644 (file)
@@ -52,7 +52,7 @@ done
 FILE=repos.txt
 
 find . -name pom.xml -print0 | xargs -0 grep -i '<repositories>\|<pluginRepositories>' > "$FILE"
-[[ $(tr -d "\r\n" < $FILE|wc -c) -eq 0 ]] && rm $FILE
+[[ $(tr -d "\\r\\n" < $FILE|wc -c) -eq 0 ]] && rm $FILE
 
 if [ -a $FILE ]
 then
index dc8753728af6547013442e110b7f259e59a08214..02cdf5b9c72021491ced30f2b357a9ab07413a81 100644 (file)
@@ -12,7 +12,7 @@
 
 script=$(mktemp)
 
-cat > $script <<EOF
+cat > "$script" <<EOF
 # SPDX-License-Identifier: EPL-1.0
 ##############################################################################
 # Copyright (c) 2017 The Linux Foundation and others.
@@ -49,7 +49,7 @@ for link in links:
 
         url = link['href']
         project = url.split('/')[3].split('-')[0]
-        _file.write("{}\t{}{}\n".format(project, jenkins_url, url))
+        _file.write("{}\\t{}{}\\n".format(project, jenkins_url, url))
 
 _file.close()
 EOF
index 0ca64fbc6ff3ca0e27e9155acb65980ae8746fcb..df660c96a9996cfb612d27d30c5e3e0dd8e8cb82 100644 (file)
@@ -30,10 +30,10 @@ readarray -t images <<< "$(grep -r _system_image: --include \*.yaml \
     | awk -F": " -e '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort | uniq)"
 
 for image in "${images[@]}"; do
-    os_image_protected=$(openstack --os-cloud $OS_CLOUD image show "$image" -f value -c protected)
+    os_image_protected=$(openstack --os-cloud "$OS_CLOUD" image show "$image" -f value -c protected)
     echo "Protected setting for $image: $os_image_protected"
     if [[ $os_image_protected != True ]]; then
         echo "Image: $image NOT set as protected, changing the protected value."
-        openstack --os-cloud $OS_CLOUD image set --protected "$image"
+        openstack --os-cloud "$OS_CLOUD" image set --protected "$image"
     fi
 done
index daa33c3db1d49864e63dc9c3d568ee5957af2593..cce9296371d1d054be7425e656f7d0a872b3902a 100644 (file)
@@ -17,7 +17,7 @@ source "/tmp/v/openstack/bin/activate"
 function copy-ssh-keys-to-slave() {
     RETRIES=60
     for j in $(seq 1 $RETRIES); do
-        # shellcheck disable=SC2092
+        # shellcheck disable=SC2006,SC2092
         if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
             ssh "jenkins@${i}" 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
             echo "Successfully copied public keys to slave ${i}"
@@ -43,7 +43,7 @@ function copy-ssh-keys-to-slave() {
 # to which VM types.
 openstack stack show -c outputs "$STACK_NAME"
 
-# shellcheck disable=SC2006
+# shellcheck disable=SC2006,SC2207
 ADDR=(`openstack stack show -f json -c outputs "$STACK_NAME" | \
        jq -r '.outputs[] | \
               select(.output_key | match("^vm_[0-9]+_ips\$")) | \
index 7e74906f32767ae154344b90b232662194238805..20ceb396e55727f1e7ed0ccf1d6bffaae677659d 100644 (file)
@@ -24,6 +24,8 @@ EOF
 # Blank line before EOF is on purpose to ensure there is spacing.
 
 IFS=$'\n'
+# We purposely want globbing here to build images list
+# shellcheck disable=SC2207
 IMAGES=($(openstack image list --long -f value -c Name -c Protected \
     | grep 'ZZCI.*True' | sed 's/ True//'))
 for i in "${IMAGES[@]}"; do
index d8fd61e581adad291a5514d75ee158fa0b8c43b1..6def490d0721d740f4215ee6ab3ca72979f3b0b5 100644 (file)
@@ -43,7 +43,7 @@ mapfile -t actual_deps < <( rpm -qp /home/$USER/rpmbuild/RPMS/noarch/*.rpm --req
 # shellcheck disable=SC2154 disable=SC2145
 printf 'Dependency found: %s\n' "${{actual_deps[@]}}"
 
-# shellcheck disable=SC2154 disable=SC2145 disable=SC2034
+# shellcheck disable=SC2154,SC2145,SC2034,SC2207
 diff_deps=(`echo "${{expected_deps[@]}}" "${{actual_deps[@]}}" | tr ' ' '\n' | sort | uniq -u`)
 # shellcheck disable=SC2154 disable=SC2145 disable=SC2068 disable=SC2170 disable=SC1083
 if [ ${{#diff_deps[*]}} -eq 0 ]; then
index 978296bb577415ebdce3b32e4e0414dd720577d4..aae30d44b1e3be34881adf56e5646a8ef1fedde7 100644 (file)
@@ -7,6 +7,8 @@ set -xeu -o pipefail
 
 enable_service() {
     # Enable services for Ubuntu instances
+    # We purposely want to allow globbing to build the package array
+    # shellcheck disable=SC2206
     services=($@)
 
     for service in "${services[@]}"; do
@@ -72,6 +74,8 @@ ensure_ubuntu_install() {
     # On Ubuntu sometimes the mirrors fail to install a package. This wrapper
     # checks that a package is successfully installed before moving on.
 
+    # We purposely want to allow globbing to build the package array
+    # shellcheck disable=SC2206
     packages=($@)
 
     for pkg in "${packages[@]}"
index 5153a4a6d5c2d6279a746b311da5fea0ce391d1e..21c2a7a07b517bf840c8912fee9e2f2abea0aa04 100644 (file)
@@ -25,7 +25,7 @@ projs="requirements keystone glance cinder neutron nova horizon"
 # shellcheck disable=SC2154
 branch=${os_branch}
 # strip the "stable" off of the branch
-branch_name=$(cut -d'/' -f2 <<< ${branch})
+branch_name=$(cut -d'/' -f2 <<< "${branch}")
 
 wget https://bootstrap.pypa.io/get-pip.py
 python get-pip.py
@@ -34,24 +34,24 @@ mkdir tmp
 cd tmp
 
 git clone https://github.com/openstack-dev/devstack.git
-(cd devstack && git checkout ${branch})
+(cd devstack && git checkout "${branch}")
 sed -e 's/#.*//' devstack/files/rpms/general | xargs yum install -y
 
 base_url=https://github.com/openstack/
 for proj in $projs
 do
-    git clone ${base_url}${proj}
-    (cd ${proj} && git checkout ${branch})
-    pip install -c requirements/upper-constraints.txt -e ${proj}
-    pip install -c requirements/upper-constraints.txt -r ${proj}/test-requirements.txt
+    git clone "${base_url}${proj}"
+    (cd "${proj}" && git checkout "${branch}")
+    pip install -c requirements/upper-constraints.txt -e "${proj}"
+    pip install -c requirements/upper-constraints.txt -r "${proj}/test-requirements.txt"
 done
 
 echo '---> Installing openvswitch from relevant openstack branch'
-yum install -y centos-release-openstack-${branch_name}
+yum install -y "centos-release-openstack-${branch_name}"
 
 yum install -y --nogpgcheck openvswitch
 
-cd $OLDPWD
+cd "$OLDPWD"
 rm -fr tmp
 
 # vim: sw=4 ts=4 sts=4 et :
index 5e32c1179d9f1b16013a6bbb0bb9e1ec8f695bed..5b599d39a4920c0e7776d896535fcb1230b653c7 100644 (file)
@@ -34,8 +34,11 @@ echo '---> Waiting 15 secs for services to start'
 sleep 15
 ovs-vsctl --version
 ovs-vsctl show
-ps -elf|grep ovs
-ps -elf|grep vtep
+# We want to see the entire ps output not just the pid
+# shellcheck disable=SC2009
+ps -elf | grep ovs
+# shellcheck disable=SC2009
+ps -elf | grep vtep
 echo '---> Finished installing OpenVSwitch 2.6.1'
 
 echo '---> Installing mininet'
index 9274388204f752c3f592037f72b34cbe3edc9d6e..b4a31e64e2447bf0f52d9b5bb147663c6a83c651 100644 (file)
@@ -52,17 +52,17 @@ cd ./util
 ./install.sh -nfv
 
 echo '---> Installing cbench installation for running openflow performance tests'
-OF_DIR=$HOME/openflow  # Directory that contains OpenFlow code
-OFLOPS_DIR=$HOME/oflops  # Directory that contains oflops repo
+OF_DIR="$HOME/openflow"  # Directory that contains OpenFlow code
+OFLOPS_DIR="$HOME/oflops"  # Directory that contains oflops repo
 
 apt-get install -y --force-yes libsnmp-dev libpcap-dev libconfig-dev
 
-git clone git://gitosis.stanford.edu/openflow.git $OF_DIR
-git clone https://github.com/andi-bigswitch/oflops.git $OFLOPS_DIR
+git clone git://gitosis.stanford.edu/openflow.git "$OF_DIR"
+git clone https://github.com/andi-bigswitch/oflops.git "$OFLOPS_DIR"
 
-cd $OFLOPS_DIR
+cd "$OFLOPS_DIR"
 ./boot.sh
-./configure --with-openflow-src-dir=$OF_DIR
+./configure --with-openflow-src-dir="$OF_DIR"
 make
 make install