2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> packer-build.sh"
12 # The script builds an image using packer
13 # $CLOUDENV : Provides the cloud credential file.
14 # $PACKER_PLATFORM : Provides the packer platform.
15 # $PACKER_TEMPLATE : Provides the packer temnplate.
17 # Ensure we fail the job if any steps fail.
20 PACKER_LOGS_DIR="$WORKSPACE/archives/packer"
21 PACKER_BUILD_LOG="$PACKER_LOGS_DIR/packer-build.log"
22 mkdir -p "$PACKER_LOGS_DIR"
23 export PATH="${WORKSPACE}/bin:$PATH"
26 export PACKER_LOG="yes" && \
27 export PACKER_LOG_PATH="$PACKER_BUILD_LOG" && \
28 packer.io build -color=false \
29 -var-file="$CLOUDENV" \
30 -var-file="../packer/vars/$PACKER_PLATFORM.json" \
31 "../packer/templates/$PACKER_TEMPLATE.json"
33 # Retrive the list of cloud providers
34 clouds=($(jq -r '.builders[].name' "../packer/templates/$PACKER_TEMPLATE.json"))
36 # Split public/private clouds logs
37 for cloud in "${clouds[@]}"; do
38 grep -e "$cloud" "$PACKER_BUILD_LOG" > "$PACKER_LOGS_DIR/packer-build_$cloud.log" 2>&1