Skip to content

Commit

Permalink
Use var for images file in rhtap task
Browse files Browse the repository at this point in the history
Short explanation: Clean up the code a little by using a variable.

Long explanation: This task gets converted to a bash script and
wrapped by a Jenkins shared library in the brand new RHTAP Jenkins
pipeline sample templates. When testing the RHTAP Jenkins pipeline I
found the default Jenkins user could not write to /tmp/, so I wanted
to change the location of the file. This refactor makes that just a
single line change, rather than having to change the path in three
places.

See also
redhat-appstudio/tssc-sample-jenkins#1
where this PR was suggested by @mmorhun, and also
redhat-appstudio/tssc-dev-multi-ci#2 where the cosign,
Enterprise Contract, and promote pipeline support was being added to
the RHTAP Jenkins templates.
  • Loading branch information
simonbaird authored and lcarva committed Aug 5, 2024
1 parent 2099988 commit 589299a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions task/gather-deploy-images/0.1/gather-deploy-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spec:
set -euo pipefail
IMAGE_PATH='.spec.template.spec.containers[0].image'
IMAGES_FILE='/tmp/all-images.txt'
component_name=$(yq .metadata.name application.yaml)
for env in "$@"; do
Expand All @@ -55,9 +56,9 @@ spec:
fi
printf "%s\n" "$image"
done | sort -u > /tmp/all-images.txt
done | sort -u > $IMAGES_FILE
if [ ! -s /tmp/all-images.txt ]; then
if [ ! -s $IMAGES_FILE ]; then
echo "No images to verify"
touch $(results.IMAGES_TO_VERIFY.path)
exit 0
Expand All @@ -66,7 +67,7 @@ spec:
# TODO: each component needs a {"source": {"git": {"url": "...", "revision": "..."}}}
# will that be too large for Tekton results?
jq --compact-output --raw-input --slurp < /tmp/all-images.txt '
jq --compact-output --raw-input --slurp < $IMAGES_FILE '
# split input file
split("\n") |
# drop empty lines
Expand Down

0 comments on commit 589299a

Please sign in to comment.