避免将Master分支用于BitBucket管道

时间:2020-06-02 19:45:38

标签: git bitbucket bitbucket-pipelines

我正在基于docker在BitBucket存储库上设置CI管道。我基本上是先运行构建命令,然后进行测试。到目前为止,所有方法都可以使用,但是我遇到的问题是仅BitBucket 提交,或者让我编辑对master分支上的 bitbucket-pipelines.yaml 文件所做的更改。 / p>

我不是该项目上唯一的开发人员,现在我们的master是我们准备/准备生产分支的分支,我们都同意使用其他分支来处理事情,让我们一个人管理master并合并到它。

我的问题是,是否可以像master活动的分支一样使用不同于master的另一个分支来“管理”我的管道文件?出于某种原因,我找不到将管道添加到另一个分支的方法,并且在developer分支上推送bitbucket-pipelines.yaml文件不会触发构建。

作为参考,我的管道Yaml:

image: atlassian/default-image:2

pipelines:
  # pull-requests:
  #   'feature/*':
  #     - step:
  #       services:
  #         - docker
  branches:
    develop:
      # each step starts a new Docker container with a clone of your repository
      - step:
        services:
          - docker
        script:
          - (cd app/laravel/ ; npm install)
          - (cd app/laravel/ ; npm run production)
          - docker build -t myApp -f app/Dockerfile app/
          - docker stack up -c docker/docker-compose.yaml myApp

2 个答案:

答案 0 :(得分:3)

您应该可以在想要的任何分支中拥有管道。
来自troubleshooting section

我的分支没有建立

确保分支的根目录中有一个bitbucket-pipelines.yml文件。

要构建分支,必须指定defaultbranch-specific管道配置。
有关更多信息,请参见Configure bitbucket-pipelines.yml

我会在branch workflow之后进行测试,首先使用简化的Yaml(仅对给定分支进行回显的Yaml)进行测试。

OP RoboBear确认in the comments时,bitbucket-pipelines.yml必须使用.yml扩展名, not .yaml

答案 1 :(得分:1)

我的问题是尚未为该仓库启用管道,并且由于我将bitbucket-pipelines.yml文件添加到了不是主分支的分支中,并且未使用入门教程,因此尚未为该管道启用管道资料库。转到存储库设置->管道|设置->启用管道。然后,您将不得不使用bitbucket-pipelines.yml将另一个更改推送到分支,它应该运行管道。