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
This commit is contained in:
Rick Bartra 2021-03-24 23:10:25 +00:00
parent 9559538d0b
commit ef3118a6d1

View File

@ -10,8 +10,12 @@ jq 'if type=="array" then . else [.] end' "/workspace/development_pipeline_data/
echo "Set image_fullname" 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" 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}" echo "Set tag to context ${CONTEXT_UID} if there is no tag pre-defined"
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" 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}" 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" 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"