git 仅特定分支上的 GitLab CI 管道
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46948990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GitLab CI Pipeline on specific branch only
提问by ProximaCygni
I'm trying to implement GitLab CI Pipelines to build and deploy an Angular app. In our project we have two general branches: master
(for production only) and develop
. For development we create feature/some-feature
branches from develop
branch. When development finished, we create merge request from feature/some-feature
to develop
. When merge request approved and merged into develop
branch I want to run a Pipeline in order to build application and deploy the build on some environment.
我正在尝试实施 GitLab CI Pipelines 来构建和部署 Angular 应用程序。在我们的项目中,我们有两个通用分支:(master
仅用于生产)和develop
. 对于开发,我们feature/some-feature
从develop
分支创建分支。开发完成后,我们从feature/some-feature
to创建合并请求develop
。当合并请求被批准并合并到develop
分支时,我想运行一个管道以构建应用程序并在某些环境中部署构建。
I use the following setup in .gitlab-ci.yml:
我在 .gitlab-ci.yml 中使用以下设置:
image: node:7.5-configured
stages:
- build
- deploy
build_job:
stage: build
only:
- develop
script:
- /bin/bash <some script here>
...
The problem is that Pipeline executed every time I push into any feature/some-feature
branch. What's wrong with my setup? How can I force the Pipeline to be executed onlywhen push performed into develop
branch directly?
问题是每次我推入任何feature/some-feature
分支时都会执行流水线。我的设置有什么问题?仅当develop
直接推送到分支时,如何才能强制执行流水线?
SolutionIt was my mistake - I had two different .gitlab-ci.yml files in develop
branch and feature/some-feature
branch.
解决方案这是我的错误 - 我在develop
分支和feature/some-feature
分支中有两个不同的 .gitlab-ci.yml 文件。
回答by ProximaCygni
It was my mistake - I had two different .gitlab-ci.yml files in develop
branch and feature/some-feature
branch and that's why the Pipeline was executed for all branches.
这是我的错误 - 我在develop
分支和feature/some-feature
分支中有两个不同的 .gitlab-ci.yml 文件,这就是为所有分支执行管道的原因。