#!/bin/bash # Copyright ETSI 2019 # See: https://forge.etsi.org/etsi-forge-copyright-statement.txt echo "------ Switching to $1 folder --------" cd $1 echo "------ Content of the folder ------" ls echo "------ Validating all YAML files ------" # If there are no YAML file, simply exit ls | grep -q yaml found_yaml=$? if [ ! $found_yaml ] ; then echo "-- No YAML files." exit 0 fi fres=0 for i in ./*.yaml ; do echo "---- Will validate: $i ----" swagger-cli validate "$i" res=$? fres=$(($fres||$res)) done # Exit code needed for jenkins to know the verdict of the build echo "-- Final validator returns $fres." exit $fres