From ef3118a6d163a3c63b0ec2831bbdbebe2e10d788 Mon Sep 17 00:00:00 2001 From: Rick Bartra Date: Wed, 24 Mar 2021 23:10:25 +0000 Subject: [PATCH] Support for using pre-defined image tags within a chart If a chart has a image tag, it should persists and not be overwritten by the dev pipeline. If there are no tags or empty tags, then the context taskrun uuid is used as the tag as it currently is. Change-Id: Ic687a8998b73c574a9d0857075c11c9205d5cbdc --- .../assets/jarvis/setup_image_config.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/gate/jarvis/standard-container/assets/jarvis/setup_image_config.sh b/tools/gate/jarvis/standard-container/assets/jarvis/setup_image_config.sh index 1e15bf91..6ca0ebca 100755 --- a/tools/gate/jarvis/standard-container/assets/jarvis/setup_image_config.sh +++ b/tools/gate/jarvis/standard-container/assets/jarvis/setup_image_config.sh @@ -10,8 +10,12 @@ jq 'if type=="array" then . else [.] end' "/workspace/development_pipeline_data/ echo "Set image_fullname" jq "reduce range(0, length) as \$d (.; (.[\$d].image_fullname=\"test/scan-image:\"+(\$d|tostring)+\"${CONTEXT_UID}\"))" "/workspace/development_pipeline_data/image.json" > "/workspace/development_pipeline_data/temp_image.json" && mv "/workspace/development_pipeline_data/temp_image.json" "/workspace/development_pipeline_data/image.json" -echo "Set tag to context ${CONTEXT_UID}" -jq "reduce range(0, length) as \$d (.; (.[\$d].tag=\"${CONTEXT_UID}\"))" "/workspace/development_pipeline_data/image.json" > "/workspace/development_pipeline_data/temp_image.json" && mv "/workspace/development_pipeline_data/temp_image.json" "/workspace/development_pipeline_data/image.json" +echo "Set tag to context ${CONTEXT_UID} if there is no tag pre-defined" +IMAGE_TAG=$(cat /workspace/development_pipeline_data/image.json | jq .'[0]'.'tag') +if [ "${IMAGE_TAG}" == "null" ] || [ "${IMAGE_TAG}" == "" ]; then + IMAGE_TAG="\"${CONTEXT_UID}\"" +fi +jq "reduce range(0, length) as \$d (.; (.[\$d].tag=${IMAGE_TAG}))" "/workspace/development_pipeline_data/image.json" > "/workspace/development_pipeline_data/temp_image.json" && mv "/workspace/development_pipeline_data/temp_image.json" "/workspace/development_pipeline_data/image.json" echo "Set target location for git repository to /workspace/development_pipeline_data/${CONTEXT_UID}" jq "reduce range(0, length) as \$d (.; (.[\$d].build.target_loc=\"/workspace/development_pipeline_data/${CONTEXT_UID}\"+.[\$d].build.repo+\"/\"+.[\$d].build.refspec))" "/workspace/development_pipeline_data/image.json" > "/workspace/development_pipeline_data/temp_image.json" && mv "/workspace/development_pipeline_data/temp_image.json" "/workspace/development_pipeline_data/image.json"