Merge branch 'fix-report-job-when-no-built-images' into 'master'

Ensure report-built-images doesn't fail when no images were built

See merge request https://gitlab.com/gitlab-org/gitlab-build-images/-/merge_requests/817

Merged-by: Rémy Coutable <remy@rymai.me>
Approved-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2024-06-03 05:42:46 +00:00
commit 0e91d03527
2 changed files with 14 additions and 2 deletions

View file

@ -57,6 +57,7 @@
-t "$CI_REGISTRY_IMAGE:$IMAGE_NAME" \
-f "Dockerfile.$IMAGE_NAME" \
.
- 'echo "${CI_JOB_URL}: ${IMAGE_NAME}" > "${CI_JOB_ID}-${CI_JOB_NAME_SLUG}-built-image.txt"'
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never

View file

@ -2,8 +2,19 @@ report-built-images:
image: alpine
stage: report
script:
- cat *-built-image.txt > all-built-images.txt
- cat all-built-images.txt
- |
set -- "${CI_PROJECT_DIR}"/*-built-image.txt
while [ "$#" -gt 0 ] && [ ! -f "$1" ]; do
shift
done
if [ -f "$1" ]; then
cat *-built-image.txt > all-built-images.txt
cat all-built-images.txt
else
echo "No images built";
fi
artifacts:
paths: ["all-built-images.txt"]
expire_in: 90d