使用curl命令

时间:2018-06-06 19:13:58

标签: shell curl bitbucket

我正在使用curl命令在bitbucket中创建拉取请求。通过curl推送失败后脚本中止。

if curl -v -w httpcode=%{http_code} -u \ 
    ${BITBUCKET_USERID}:${BITBUCKET_PASSWORD} -H "Content-Type: \ 
    application/json" -X POST -d "$json_data" \
    $url/rest/api/1.0/projects/$project/repos/$repo/pull-requests >> $log_file 2>&1 ; then

    PR_URL=$(grep -o "https://bitbucket.com/projects/[a-zA-Z_-]*/repos/[a-zA-Z_-]*/pull-requests/[0-9]*" $log_file | tail -1)

else
    error "curl command failed with exit code:$curl_exit_code and http code:$httpcode"
fi

当没有推送失败时,curl命令正常工作。

Please find the error log:
-> Pushing branch {repo}:auto-test-0606 ...(ok)
-> Creating Pull Request for {repo} (auto-test-0606 -> master)...
PR_URL: https://bitbucket.ciena.com/projects/{project}/repos/{project}/pull-requests/{pr_id}
-> Pushing branch {repo1}:auto-test-0606 ...
Error: Push failed with error message: Repository not found
The requested repository does not exist, or you do not have permission to access it.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
-bash-4.2$

需要创建更多的repos,但脚本意外中止。请帮助解决问题。提前致谢

0 个答案:

没有答案