Skip to content

Exit `wait_for_job_to_be_done` as error if the job fails

Mark Lapierre requested to merge exit-error-if-job-waited-fails into master

What does this MR do?

If a script is waiting for a job to be done and that job fails, exit with an error status so that the script doesn't continue with a prerequisite in an invalid state.

More info

For example this package-and-qa job was waiting for gitlab:assets:compile to complete, but it failed and package-and-qa continued: https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/137873724

$ wait_for_job_to_be_done "gitlab:assets:compile"
GET https://gitlab.com/api/v4/projects/13083/pipelines/41025847/jobs?per_page=100&page=1
GET https://gitlab.com/api/v4/projects/13083/pipelines/41025847/jobs?per_page=100&page=2
The 'gitlab:assets:compile' job ID is 137873857
Waiting for the 'gitlab:assets:compile' job to finish...
GET https://gitlab.com/api/v4/projects/13083/jobs/137873857
............................Waited 'gitlab:assets:compile' for 14 minutes.
The 'gitlab:assets:compile' failed.
$ ./$SCRIPT_NAME omnibus
Triggered downstream pipeline: https://gitlab.com/gitlab-org/omnibus-gitlab/pipelines/41028166

And then all the qa jobs failed: https://gitlab.com/gitlab-org/gitlab-qa/pipelines/41034645

What are the relevant issue numbers?

Does this MR meet the acceptance criteria?

/cc @rymai just FYI

Merge request reports