]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/ceph-backport.sh: stop if GitHub API returns "null"
authorNathan Cutler <ncutler@suse.com>
Thu, 5 Sep 2019 09:53:47 +0000 (11:53 +0200)
committerNathan Cutler <ncutler@suse.com>
Fri, 6 Sep 2019 10:23:33 +0000 (12:23 +0200)
Signed-off-by: Nathan Cutler <ncutler@suse.com>
src/script/ceph-backport.sh

index 0b0f6780d8b0094fc51a6686c9acb2840f0eb803..d3ccccbf87afe4c53416b5816bba3cadbe3fb3c7 100755 (executable)
@@ -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"