我有一个CI teamcity构建,我们将使用Bitbucket API来创建一个拉取请求。构建链的设计方式是,对PR的注释"build this“将触发构建链。目前,这个过程(创建PR和添加评论)是手动完成的;我们正在尝试自动化这一过程。
我们能够通过PR成功创建PR;
curl -k -X POST -H "Content-Type: application/json" -u sysAccount:sysPasswd https://stash.org.com:1234/rest/api/1.0/projects/MyProjName/repos/MyRepoName/pull-requests -d '{ "title": "Pull Request Test", "description": "My PR", "state": "OPEN", "open": true, "closed": false, "fromRef": { "id": "refs/heads/myFeatureBranch", "repository": { "slug": "MyPrivateRepo", "name": "MyPrivateRepo", "project": { "key": "~SystemAccount" } } }, "toRef": { "id": "refs/heads/master", "repository": { "slug": "PublicRepoName", "name": "PublicRepoName", "project": { "key": "TeamPrjName" } } }, "locked": false, "reviewers": [] }'和另一个添加注释的API调用:
curl -k -X POST -H "Content-Type: application/json" -u sysAccount:sysPasswd https://stash.org.com:1234/rest/api/1.0/projects/MyProjName/repos/MyRepoName/pull-requests/12345/comments -d '{ "text": "build this" }'但是,我们如何检索id (即本例中的12345 )。我们可以获得此PR的完整JSON响应;但是,我只需要pullRequestId
发布于 2019-07-04 12:51:56
您可以使用Pull Request Notifier并构造一个网址,如下所示:
https://stash.org.com:1234/rest/api/1.0/projects/MyProjName/repos/MyRepoName/pull-requests/${PULL_REQUEST_ID}/commentshttps://stackoverflow.com/questions/56869006
复制相似问题