为多个项目创建一个bitbucket-pipelines.yml文件

时间:2020-02-05 21:10:11

标签: bitbucket-pipelines

我有大量具有相同管道需求(目前非常简单:构建,测试,部署)的微服务(40多个)。他们每个人都住在自己的存储库中。显然,随着我们改进管道,我想避免在40个地方更改bitbucket-pipelines.yml文件。我知道travis和gitlab都提供了导入/包含功能,可让您包含“主” yml文件。 Bitbucket管道有类似的东西吗?如果没有,可行的替代方法是什么?

谢谢!

2 个答案:

答案 0 :(得分:0)

您应该能够通过使用自定义的Bitbucket Pipe来做到这一点。例如,您可以构建一个自定义管道来部署代码并将其添加到bitbucket-pipelines.yml中。这是一个示例:

pipelines:
  default:
    - step:
        name: "Deployment step"
        script:
          - pipe: your-bitbucket-account/deploy-pipe:1.0.0
            variables:
              KEY: 'value'

这里是指向文章的链接,该文章解释了如何编写自定义管道https://bitbucket.org/blog/practice-devops-with-custom-pipes-reusing-ci-cd-logic

答案 1 :(得分:0)

这对我有用,我必须为多个项目的解决方案设置bitbucket管道。

您将必须在管道名称之前添加管道中的custom:属性

pipelines:
 custom:
 deployAdminAPI:
     - step:
         name: Build and Push AdminAPI
         script: enter your script
 deployParentsAPI:
     - step:
         name: Build and Push ParentsAPI
         script: enter your script

这是Bitbucket解决方案的Link