Bitbucket API 2-在团队项目中创建存储库 [英] Bitbucket API 2 - create repository in a team project
问题描述
我的比特币帐户中有一个团队 myteam
,其中包含一个名为 mainproject
的项目。每当我想在内部创建存储库时,只需执行以下命令行即可:
I have a team on my bitbucket account, myteam
, which contains a project named mainproject
. Whenever I want to create a repository inside I only need to execute this command line:
$ curl -X POST -v -u myaccount:passwd "https://api.bitbucket.org/2.0/repositories/myteam/repo1" -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks"}'
这有效。但是,当我创建另一个名为 secondproject
的项目时,就会出现问题。我应该如何告诉API存储库应属于哪个项目?
This works. However the issue arises when I create a second project, named secondproject
. How am I supposed to tell the API to which project the repository should belong?
我尝试在数据(-d)中指定项目信息:
I tried specifying the project information in the data (-d):
$ curl -X POST -v -u myaccount:passwd "https://api.bitbucket.org/2.0/repositories/myteam/repo2" -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks", "project": {"name": "secondproject"} }'
或具有关键参数:
$ curl -X POST -v -u myaccount:passwd "https://api.bitbucket.org/2.0/repositories/myteam/repo2" -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks", "project": {"key": "SEC"} }'
这将在项目<$中创建存储库repo2 c $ c> mainproject 。
我尝试使用uuid,但同样发生,在主项目中创建了repo。
I tried using the uuid but the same occurs, repo is created in the mainproject.
我尝试将项目名称放在链接中:
I tried putting the project name in the link:
$ curl -X POST -v -u myaccount:passwd "https://api.bitbucket.org/2.0/repositories/myteam/secondproject/repo1" -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks"
...
{"error": {"message": "Resource not found", "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://confluence.atlassian.com/x/IYBGDQ"}}
如何指定要存储库的项目创建属于?
我不是在寻找GUI解决方案,我想坚持使用命令行,因为我需要以这种方式自动创建存储库。
How can I specify which project the repository I want to create belongs to? I am not looking for a GUI solution, I want to stick to the command line as I need to automatize the creation of repositories this way.
推荐答案
必须使用此参数将内容类型指定为 curl
: -H内容类型:application / json
。然后 json
数据将被正常访问。因此,最终的推荐如下:
The content type has to be specified to curl
with this argument: -H "Content-Type: application/json"
. Then the json
data would be accessed normally. So the end commend would look like this:
$ curl -X POST -v -u myaccount:passwd "https://api.bitbucket.org/2.0/repositories/myteam/repo2" -H "Content-Type: application/json" -d '{"has_wiki": true, "is_private": true, "project": {"key": "PRJ_KEY"}}'
这篇关于Bitbucket API 2-在团队项目中创建存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!