我正在基于 docker 的 BitBucket 存储库上设置 CI 管道。基本上,我正在运行构建命令然后进行测试。到目前为止,这一切都有效,但我遇到的问题是 BitBucket 只有提交或让我编辑对 master 分支上的 bitbucket-pipelines.yaml 文件的更改。
我不是该项目的唯一开发人员,现在我们的 master 是我们的 staging/ready for prod 分支,我们都同意使用其他分支来做事情,让我们中的一个人管理 master 并 merge 到其中。
我的问题是,我可以使用另一个不同于 master 的分支来“管理”我的管道文件,比如我们的事件开发分支吗?出于某种原因,我找不到将管道添加到另一个分支的方法,并且在开发分支上推送 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
最佳答案
您应该能够在您想要的任何分支中拥有管道。
来自 troubleshooting section :
My branch doesn't build
Make sure that there is a
bitbucket-pipelines.yml
file in the root of your branch.To build a branch, you must specify a
default
or abranch-specific
pipeline configuration.
For more information, see Configure bitbucket-pipelines.yml.
我会在 branch workflow 之后进行测试,首先使用简化的 yaml(一个只对给定分支进行回显),用于测试。
如 OP RoboBear确认 in the comments ,
bitbucket-pipelines.yml
必须使用 .yml
扩展名,而不是 .yaml
.
关于git - 避免在 BitBucket 管道中使用 Master 分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62160195/