如何在多分支中触发Bitbucket管道 [英] How to trigger bitbucket pipeline in multibranch
问题描述
我在位桶帐户下有一个存储库,该存储库具有这4个分支:
I have a single repository under bit-bucket account and this repository has this 4 branches :
- master
- API
- Admin
- Web
而且我在 master分支
下只有一个 bitbucket-pipelines.yml
,其内容如下:
and I have only one bitbucket-pipelines.yml
under master branch
and its like that :
image: maven:3.5.0-jdk-7
pipelines:
branches:
API:
- step:
caches:
- maven
script:
- mvn install
所以我希望每当对API分支进行任何推送都会触发该管道,实际上只有在对master分支进行推送之后它才会发生,唯一的出路是将相同的文件也放在API下分支也是如此,尽管该文档说它只有一个副本位于repo根 master分支
下,那么如何实现该plz?
so I expect that whenever any push happened to API branch will trigger this pipeline, bit in fact it didn't happen unless the push is done to the master branch, the only way out is to put this same file also under API branch as well, although the doc says its only one copy located under repo root master branch
, So how can I achieve that plz?
如果我需要在所有分支中放置相同的管道文件,我会完全嘲笑它,那么任何一个plz都可以澄清这一点吗?提前致谢!
and if I need to put same pipeline file in all branches I see it completely ridicules, so can any one plz clarify that? Thanks in advance!
推荐答案
如果您在 master
中只有一个 bitbucket-pipelines.yml
,则没有当您按下
,因此不会运行任何管道.就这么简单.您引用的文档中的仅一个副本"语句对我来说并没有太大意义,因为YAML文件仅位于Git中,因此是分支相关的,即 API
时> bitbucket-pipelines.yml bitbucket-pipelines.yml
是与其他文件一样的文件,并且在分支时没有特殊"要求.
If you only have a bitbucket-pipelines.yml
in master
, then there is no bitbucket-pipelines.yml
when you push to API
, and therefore no pipeline will run. It’s as simple as that. The "only one copy" statement from the docs which you refer to doesn’t make too much sense to me, as the YAML file just is in Git, and therefore is branch-dependend, i.e. bitbucket-pipelines.yml
is a file like any other file and there is nothing "special" about it when it comes to branches.
但是,我明白了您为什么感到困惑–为什么要有一个单个配置文件来指定每个分支的行为,而每个人可能只是在每个分支?我认为这样做的理由是通常配置将非常相似.例如,大多数存储库将具有诸如 develop
和 master
之类的分支,这些分支可能仅在部署位置上有所不同.在分支中使用不同的文件会更麻烦.
However, I see why you are confused – why have a single config file that specifies behavior for each branch, while one could just have a branch-specific config in each branch? I assume the rationale behind this is that usually the configurations will be very similar. For example, most repos will have branches such as develop
and master
which might only differ in where they are deployed. Having distinct files in the branches would be more awkward to work with.
在您问:是之前,您可以可以配置2个以上的分支来执行相同的操作.至少有两种可能的语法,最简单的一种是这样:
And before you ask: yes, you can configure 2+ branches to perform the same action(s). There are at least 2 possible syntaxes, and the easiest one is this:
pipelines:
branches:
'{develop,master,release/*}':
- step:
script:
- echo $BITBUCKET_BRANCH
这篇关于如何在多分支中触发Bitbucket管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!