From: Andrew Grimberg Date: Wed, 10 Jun 2020 16:01:13 +0000 (-0700) Subject: Correctly evaluate UPDATE_CLOUD_IMAGE X-Git-Tag: v0.55.0^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=5fc616e4b1231808c1f11608608415312b08aa02;p=releng%2Fglobal-jjb.git Correctly evaluate UPDATE_CLOUD_IMAGE 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 --- diff --git a/releasenotes/notes/fix_packer_build-3d4cc3519be3c2a7.yaml b/releasenotes/notes/fix_packer_build-3d4cc3519be3c2a7.yaml new file mode 100644 index 00000000..6f78acbe --- /dev/null +++ b/releasenotes/notes/fix_packer_build-3d4cc3519be3c2a7.yaml @@ -0,0 +1,9 @@ +--- +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. diff --git a/shell/packer-build.sh b/shell/packer-build.sh index 3349a723..1a44e4fd 100644 --- a/shell/packer-build.sh +++ b/shell/packer-build.sh @@ -68,7 +68,7 @@ packer.io build -color=false \ "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}')