diff --git a/ci/get_id_of_last_job_occurence.py b/ci/get_id_of_last_job_occurence.py index 465d4c19a1ce077daed574761214a31740b83588..f7540523b9e24295729df259205eb832b157c8a5 100755 --- a/ci/get_id_of_last_job_occurence.py +++ b/ci/get_id_of_last_job_occurence.py @@ -65,9 +65,12 @@ def get_job_id(branch_name, job_name, project_id, success_only): if job_name not in resp_jobs.text: continue - # find actual job by name + # find actual job by name, exclude timed out or stuck jobs for job in resp_jobs.json(): - if job["name"] == job_name: + name_matches = job["name"] == job_name + is_success = job["status"] == "success" + has_timed_out = job.get("failure_reason", "") == "stuck_or_timeout_failure" + if name_matches and (is_success or not has_timed_out): job_id = job["id"] break if job_id >= 0: