# Stage to pull and push image
job1:
stage: job1
allow_failure: true
script:
# Pull image and save success
- docker pull ${SOURCE_IMAGEURI}:${TAG}
...
- docker tag ${SOURCE_IMAGEURI}:${TAG} ${TARGET_IMAGEURI}:${TAG}
# Job might fail here due to not enough permissions which is what I want to happen
- docker push ${TARGET_IMAGEURI}:${TAG}
- echo "Error Message" > curldata.txt
artifacts:
when: always
paths:
- curldata.txt
job2:
stage: job2
script:
# Do something with the error that happened in job1
when: always
dependencies:
- job1
So above is a part of a job that pulls and pushes an image. Sometimes the image will fail to push though as a safety step due to lack of permissions. How would I capture the error that happens so that I can send that artifacts to the next feedback job. This job will send the information to the user so he/she knows that they didnt have enough permissions.