X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fpacker-validate.sh;fp=shell%2Fpacker-validate.sh;h=e19c973ab91971ef10770cfd82d5c887e2a556b0;hb=10821edc619b09e4623884b02900c39431f8a809;hp=0000000000000000000000000000000000000000;hpb=c08bbada6e92c88817f2f591285347f9a7b4a732;p=releng%2Fglobal-jjb.git diff --git a/shell/packer-validate.sh b/shell/packer-validate.sh new file mode 100644 index 00000000..e19c973a --- /dev/null +++ b/shell/packer-validate.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2017 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## +echo "---> packer-validate.sh" +# The script validates an packers files. + +# $CLOUDENV : Provides the cloud credential file. + +# Ensure we fail the job if any steps fail. +set -eu -o pipefail + +PACKER_LOGS_DIR="$WORKSPACE/archives/packer" +mkdir -p "$PACKER_LOGS_DIR" +export PATH="${WORKSPACE}/bin:$PATH" + +cd packer +varfiles=(../packer/vars/*) +templates=(../packer/templates/*) + +for varfile in "${varfiles[@]}"; do + [[ "${varfile##*/}" =~ ^(cloud-env.*)$ ]] && continue + 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 + fi + done +done