Bitbucket : 是否可以每个分支有一个bitbucket-pipelines.yml文件?

问题描述 投票:1回答:1

我希望每个分支有一个管道

我把一个放在分支开发上,另一个放在分支主干上,但它们没有被考虑在内。

bitbucket bitbucket-pipelines
1个回答
1
投票

是的,这是有可能的。

但是,你不需要为每个分支设置一个不同的文件。你可以在同一个文件中为每个分支组织流水线,按照 文件.

设置管道的最好方法是定义每个步骤,然后为你想要的每个分支调用步骤。

不要忘记定义 默认 步骤 (这些步骤将为你之前没有定义的每个分支运行)。

你的 bitbucket-pipelines 文件应该是这样的。

image: python:3.7.3
definitions:
  steps:   
    - step: &test
        name: Test project
        caches:
          - pip
        script:
          - apt-get -y update
          - pip install --upgrade pip
          - pip install -r requirements.txt
          - python -m unittest discover tests

    - step: &lint
        name: Execute linter
        script:
          - pip install flake8
          - chmod a+x ./linter.sh
          - ./linter.sh

    - step: &bump
        name: Bump version
        script:
          - git config remote.origin.url $BITBUCKET_URL_ORIGIN
          - python bump.py

pipelines:
  branches:
    master:
    - step: *test
    - step: *lint
    - step: *bump

    develop:
    - step: *test
    - step: *lint

  default:
    - step: *lint
© www.soinside.com 2019 - 2024. All rights reserved.