From 97b6b658ad554336963a9d18455d05ec9457514b Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Thu, 5 Sep 2019 11:53:47 +0200 Subject: [PATCH] script/ceph-backport.sh: stop if GitHub API returns "null" Signed-off-by: Nathan Cutler --- src/script/ceph-backport.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/script/ceph-backport.sh b/src/script/ceph-backport.sh index 0b0f6780d8b..d3ccccbf87a 100755 --- a/src/script/ceph-backport.sh +++ b/src/script/ceph-backport.sh @@ -445,7 +445,13 @@ if [[ $title =~ \" ]] ; then fi debug "Opening backport PR" -number=$(curl --silent --data-binary '{"title":"'"$title"'","head":"'$github_user':'$local_branch'","base":"'$target_branch'","body":"'"${desc}"'"}' 'https://api.github.com/repos/ceph/ceph/pulls?access_token='$github_token | jq -r .number) +remote_api_output=$(curl --silent --data-binary '{"title":"'"$title"'","head":"'$github_user':'$local_branch'","base":"'$target_branch'","body":"'"${desc}"'"}' 'https://api.github.com/repos/ceph/ceph/pulls?access_token='$github_token) +number=$(echo "$remote_api_output" | jq -r .number) +if [ "$number" = "null" ] ; then + error "Remote API call failed" + echo "$remote_api_output" + exit 1 +fi component=${COMPONENT:-core} info "Opened backport PR ${github_endpoint}/pull/$number" debug "Setting ${component} label" -- 2.39.5