配置位桶存储库以“激活”密码存储库。管道 [英] Configuring a bitbucket repository to "activate" pipelines
本文介绍了配置位桶存储库以“激活”密码存储库。管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在BitBucket项目中有多个存储库。
我希望自动创建一个bitbucket存储库并启用管道(通过推送bitbucket-pipelines.yml文件,设置管道配置应该很容易)。
如何使用REST API?
I have multiple repositories in a BitBucket project. I wish to automatically create a bitbucket repository, and enable pipelines (setting the pipeline configuration should be easy, with pushing a bitbucket-pipelines.yml file). How can I do it using the REST API?
推荐答案
您可以使用BitBucket REST API创建存储库。
You can create a repository with the BitBucket REST API.
$ curl -X POST -H "Content-Type: application/json" -d '{
"scm": "git",
"project": {
"key": "Foo"
}
}' https://api.bitbucket.org/2.0/repositories/<username>/<repo_slug>
将您的 bitbucket-pipelines.yml
推送到
curl https://api.bitbucket.org/2.0/repositories/<username>/<slug>/src \
-F /bitbucket-pipelines.yml=@bitbucket-pipelines.yml
然后为您的项目启用管道
curl -X PUT -is -u '<username>:<password>' -H 'Content-Type: application/json' \
https://api.bitbucket.org/2.0/repositories/<username>/<repo_slug> \
-d '{
"enabled": true,
"type": "repository_pipelines_configuration"
}'
最后,您可以像这样触发分支的管道。
$ curl -X POST -is -u <username>:<password> \
-H 'Content-Type: application/json' \
https://api.bitbucket.org/2.0/repositories/<username>/<slug>/pipelines/ \
-d '
{
"target": {
"ref_type": "branch",
"type": "pipeline_ref_target",
"ref_name": "<branch_name>"
}
}'
参考文献:
查看全文