Bitbucket Pull Request refspec

时间:2016-02-05 04:45:06

标签: jenkins bitbucket

我搜索了Atlassian文档并找到了这个ref/pull-requests/$PR_NO/from,当我尝试获取它时,我遇到了这个错误Couldn't find remote ref refs/pull-requests/1/from。有没有办法启用此参考?或者webhooks是唯一的选择吗?我正在尝试使用Bitbucket进行CI设置。

(我们是10用户付费计划)

3 个答案:

答案 0 :(得分:2)

现在可以了。您只需要在<repo_root>/.git/config

中添加这样的一行
[remote "origin"]
    url = ...
    fetch = ...
    fetch = +refs/pull-requests/*:refs/pull-requests/*

当你获取时,你会看到一组全新的参考出现:

$ git fetch origin
remote: Counting objects: 252, done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 82 (delta 20), reused 0 (delta 0)
Unpacking objects: 100% (82/82), done.
From ...
 * [new ref]           refs/pull-requests/300/from  -> refs/pull-requests/300/from
 * [new ref]           refs/pull-requests/300/merge -> refs/pull-requests/300/merge
 * [new ref]           refs/pull-requests/302/from  -> refs/pull-requests/302/from
 * [new ref]           refs/pull-requests/323/from  -> refs/pull-requests/323/from
 * [new ref]           refs/pull-requests/323/merge -> refs/pull-requests/323/merge
 * [new ref]           refs/pull-requests/344/from  -> refs/pull-requests/344/from
 * [new ref]           refs/pull-requests/344/merge -> refs/pull-requests/344/merge
 * [new ref]           refs/pull-requests/350/from  -> refs/pull-requests/350/from
 * [new ref]           refs/pull-requests/350/merge -> refs/pull-requests/350/merge
 * [new ref]           refs/pull-requests/355/from  -> refs/pull-requests/355/from
 * [new ref]           refs/pull-requests/355/merge -> refs/pull-requests/355/merge

*/from为您提供PR分支机构负责人; */merge为您提供将PR与目标分支合并的结果。

有关详细信息,请参阅Pull request proficiency: Fetching abilities unlocked!

答案 1 :(得分:1)

答案 2 :(得分:1)

由Bitbucket Server(存储)(自托管)支持

Stash支持refspecs,可通过以下命令使用

git config --add remote.origin.fetch '+refs/pull-requests//from:refs/remotes/origin/pr/'

您可以对照.git / config文件检查其设置是否正确

[remote "upstream"]
url = git@stash.atlassian.com:docker/libswarm.git
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch = +refs/pull-requests/*/from:refs/remotes/upstream/pr/*

https://www.atlassian.com/blog/archives/how-to-fetch-pull-requests

不受Bitbucket Cloud(bitbucket.com)支持

Bitbucket Cloud当前不支持refspec上的PR,可用选项是轮询Bitbucket的Git或API端点

https://jira.atlassian.com/browse/BCLOUD-5814

鉴于该请求已被搁置7年,因此最好不要等待refspec的实施(截至2019年11月)