X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fpacker-validate.sh;h=61e14313ac6739c6e7e5fc5fa3f0f762bef4820e;hb=refs%2Fheads%2Fv0.48.x;hp=e9f1a8f0af4901656f9b48f5cd1b52fd32cbed6d;hpb=73c0c7ed8afa17596a835fe8e51367dff3708ce0;p=releng%2Fglobal-jjb.git diff --git a/shell/packer-validate.sh b/shell/packer-validate.sh index e9f1a8f0..61e14313 100644 --- a/shell/packer-validate.sh +++ b/shell/packer-validate.sh @@ -21,17 +21,26 @@ mkdir -p "$PACKER_LOGS_DIR" export PATH="${WORKSPACE}/bin:$PATH" cd packer -varfiles=(../packer/vars/*.json) -templates=(../packer/templates/*.json) +varfiles=(vars/*.json common-packer/vars/*.json) +templates=(templates/*.json) for varfile in "${varfiles[@]}"; do + # cloud-env.json is a file containing credentials which is pulled in via + # CLOUDENV variable so skip it here. Also handle the case where a project + # has not vars/*.json file. + if [[ "$varfile" == *"cloud-env.json"* ]] || [[ "$varfile" == 'vars/*.json' ]]; then + continue + fi + + echo "-----> Testing varfile: $varfile" for template in "${templates[@]}"; do - export PACKER_LOG="yes" && \ - export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log" && \ - packer.io validate -var-file="$CLOUDENV" \ - -var-file="$varfile" "$template" - if [ $? -ne 0 ]; then - break + export PACKER_LOG="yes" + export PACKER_LOG_PATH="$PACKER_LOGS_DIR/packer-validate-${varfile##*/}-${template##*/}.log" + if output=$(packer.io validate -var-file="$CLOUDENV" -var-file="$varfile" "$template"); then + echo "$template: $output" + else + echo "$template: $output" + exit 1 fi done done