配置位桶存储库以“激活”密码存储库。管道 [英] Configuring a bitbucket repository to "activate" pipelines

查看:110
本文介绍了配置位桶存储库以“激活”密码存储库。管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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>"
    }
  }'



参考文献:




  • 存储库API

  • 管道API

  • References:

    • Repository API
    • Pipelines API
    • 这篇关于配置位桶存储库以“激活”密码存储库。管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆