Merge "Have jflint fail invalid declarative pipeline groovy"
diff --git a/jjb/shell/jflint.sh b/jjb/shell/jflint.sh
index 0972793..18c5b40 100755
--- a/jjb/shell/jflint.sh
+++ b/jjb/shell/jflint.sh
@@ -23,6 +23,8 @@
 JENKINS_URL=https://jenkins.opencord.org/
 JF_LIST=()
 
+JF_FAIL=0
+
 # if no args, and there's a Jenkinsfile in cwd, check it
 if [ ! -n "$1" ] && [ -f "Jenkinsfile" ] ; then
   JF_LIST+=("Jenkinsfile")
@@ -39,10 +41,22 @@
 fi
 
 # JENKINS_CRUMB is needed if your Jenkins master has CRSF protection enabled as it should
-JENKINS_CRUMB=$(curl "$JENKINS_URL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)")
+JENKINS_CRUMB=$(curl -s "$JENKINS_URL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)")
 
 for target in "${JF_LIST[@]-}"; do
-  echo "Checking '${target}'"
-  curl -X POST -H "${JENKINS_CRUMB}" -F "jenkinsfile=<${target}" $JENKINS_URL/pipeline-model-converter/validate
+  echo "Checking: '${target}'"
+  CURL_OUT=$(curl -s -H "${JENKINS_CRUMB}" -F "jenkinsfile=<${target}" $JENKINS_URL/pipeline-model-converter/validate)
+
+  # Jenkins doesn't set a HTTP failure code when validation fails, so check output
+  if [[ $CURL_OUT =~ Jenkinsfile\ successfully\ validated ]]
+  then
+    echo "Validated successfully: '${target}'"
+  else
+    echo "Failed to validate: '${target}' - errors:"
+    echo "$CURL_OUT"
+    JF_FAIL=1
+  fi
+
 done
 
+exit $JF_FAIL