From 7d981a949dec5bb9d444fe0da8dcc8a224882d0b Mon Sep 17 00:00:00 2001
From: Albert Salim <asalim@gitlab.com>
Date: Wed, 16 Sep 2020 11:55:53 +0800
Subject: [PATCH] Fix script to fail pipeline early

- Check for "null" value in `get_job_id`
---
 scripts/utils.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/utils.sh b/scripts/utils.sh
index 5218c1e2d98c1..9d188fc7b7783 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -110,7 +110,7 @@ function get_job_id() {
     let "page++"
   done
 
-  if [[ "${job_id}" == "" ]]; then
+  if [[ "${job_id}" == "null" ]]; then # jq prints "null" for non-existent attribute
     echoerr "The '${job_name}' job ID couldn't be retrieved!"
   else
     echoinfo "The '${job_name}' job ID is ${job_id}"
@@ -142,7 +142,7 @@ function fail_pipeline_early() {
   local dont_interrupt_me_job_id
   dont_interrupt_me_job_id=$(get_job_id 'dont-interrupt-me' 'scope=success')
 
-  if [[ "${dont_interrupt_me_job_id}" != "" ]]; then
+  if [[ -n "${dont_interrupt_me_job_id}" ]]; then
     echoinfo "This pipeline cannot be interrupted due to \`dont-interrupt-me\` job ${dont_interrupt_me_job_id}"
   else
     echoinfo "Failing pipeline early for fast feedback due to test failures in rspec fail-fast."
-- 
GitLab