While trying to get a clean packer build on an AWS based Jenkins I kept
running into the packer job failing. Digging into the code and turning
on debugging allowed me to spot that
if [[ ${UPDATE_CLOUD_IMAGE} ]]; then
Was translating to
[[ -n false ]]
During runs where $UPDATE_CLOUD_IMAGE wasn't set. This seemed strange to
me and then looking a bit further I realized that the boolean variable
in Jenkins is converting to a string ENV var of either 'true' or 'false'
depending the set. This means for the if statement to properly execute
it must evaluate as a string comparison as the variable is not actually
a boolean.
Change-Id: Ie98b51eb22412705c8c264b61be3c76b4e5ff985
Issue: RELENG-2985
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
--- /dev/null
+---
+fixes:
+ - |
+ The packer merge job has a boolean option that sets an UPDATE_CLOUD_IMAGE
+ variable. This variable was always evaluating to true which caused issues
+ with builds always executing the section of the build. This causes problems
+ for builds that do not produce information that is expected by the section
+ of code. In specific AWS / EC2 builds fail as the build engine outputs
+ different name data than expected. The variable is now properly evaluated.
"templates/$PACKER_TEMPLATE.json"
# Extract image name from log and store value in the downstream job
-if [[ ${UPDATE_CLOUD_IMAGE} ]]; then
+if [[ ${UPDATE_CLOUD_IMAGE} == 'true' ]]; then
NEW_IMAGE_NAME=$(grep -P '(\s+.*image: )(ZZCI\s+.*\d+-\d+\.\d+)' \
"$PACKER_BUILD_LOG" | awk -F': ' '{print $4}')