[CORD-3083]
Verify jobs on automation-tools repo
Add shellcheck linting

Change-Id: Iddcf439a0f2f8046309c999a0a3b3f7774925849
diff --git a/jjb/shell/ansiblelint.sh b/jjb/shell/ansiblelint.sh
index beb0891..f97d186 100755
--- a/jjb/shell/ansiblelint.sh
+++ b/jjb/shell/ansiblelint.sh
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# ansiblelint.sh - check all yaml files that they pass the ansible-lint tool
+
 set +e -u -o pipefail
 fail_ansible=0
 
@@ -24,14 +26,16 @@
 WORKSPACE=${WORKSPACE:-.}
 
 echo "=> Linting Ansible Code with $(ansible-lint --version)"
-for f in $(find "${WORKSPACE}" -type f -name "*.yml" -o -name "*.yaml"); do
-    echo "==> CHECKING: ${f}"
-    ansible-lint -p "${f}"
-    rc=$?
-    if [[ $rc != 0 ]]; then
-        echo "==> LINTING FAIL: ${f}"
-        fail_ansible=1
-    fi
-done
+
+while IFS= read -r -d '' yf
+do
+  echo "==> CHECKING: ${yf}"
+  ansible-lint -p "${yf}"
+  rc=$?
+  if [[ $rc != 0 ]]; then
+    echo "==> LINTING FAIL: ${yf}"
+    fail_ansible=1
+  fi
+done < <(find "${WORKSPACE}" \( -name "*.yml" -o -name "*.yaml" \) -print0)
 
 exit ${fail_ansible}