Skip to content

Commit 49ea74a

Browse files
committed
fix(tekton): use correct jq format for array results
Use jq -cn with $ARGS.positional to properly format the JSON array for Tekton typed array results. The previous approach with printf and jq -R was causing malformed array values.
1 parent 9439869 commit 49ea74a

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

.tekton/base-image-multiarch-pull-request-pipeline.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,11 @@ spec:
336336
CONVERTED_REFS+=("${NEW_IMAGE_REF}")
337337
done
338338
339-
# Write array result as JSON
340-
printf '%s\n' "${CONVERTED_REFS[@]}" | jq -R . | jq -s . > "$(results.IMAGE_REFS.path)"
339+
# Write array result as JSON array (Tekton format for typed array results)
340+
# Each element must be properly JSON-escaped
341+
echo "[$(date --utc -Ins)] Writing ${#CONVERTED_REFS[@]} image refs to results"
342+
jq -cn '$ARGS.positional' --args "${CONVERTED_REFS[@]}" > "$(results.IMAGE_REFS.path)"
343+
cat "$(results.IMAGE_REFS.path)"
341344
echo "[$(date --utc -Ins)] All conversions complete"
342345
securityContext:
343346
capabilities:

.tekton/base-image-multiarch-push-pipeline.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,11 @@ spec:
399399
CONVERTED_REFS+=("${NEW_IMAGE_REF}")
400400
done
401401
402-
# Write array result as JSON
403-
printf '%s\n' "${CONVERTED_REFS[@]}" | jq -R . | jq -s . > "$(results.IMAGE_REFS.path)"
402+
# Write array result as JSON array (Tekton format for typed array results)
403+
# Each element must be properly JSON-escaped
404+
echo "[$(date --utc -Ins)] Writing ${#CONVERTED_REFS[@]} image refs to results"
405+
jq -cn '$ARGS.positional' --args "${CONVERTED_REFS[@]}" > "$(results.IMAGE_REFS.path)"
406+
cat "$(results.IMAGE_REFS.path)"
404407
echo "[$(date --utc -Ins)] All conversions complete"
405408
securityContext:
406409
capabilities:

.tekton/multiarch-pipeline.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,11 @@ spec:
419419
CONVERTED_REFS+=("${NEW_IMAGE_REF}")
420420
done
421421
422-
# Write array result as JSON
423-
printf '%s\n' "${CONVERTED_REFS[@]}" | jq -R . | jq -s . > "$(results.IMAGE_REFS.path)"
422+
# Write array result as JSON array (Tekton format for typed array results)
423+
# Each element must be properly JSON-escaped
424+
echo "[$(date --utc -Ins)] Writing ${#CONVERTED_REFS[@]} image refs to results"
425+
jq -cn '$ARGS.positional' --args "${CONVERTED_REFS[@]}" > "$(results.IMAGE_REFS.path)"
426+
cat "$(results.IMAGE_REFS.path)"
424427
echo "[$(date --utc -Ins)] All conversions complete"
425428
securityContext:
426429
capabilities:

0 commit comments

Comments
 (0)