【问题标题】:Bitbucket : is it possible to have one bitbucket-pipelines.yml file per branch?Bitbucket:每个分支是否可以有一个 bitbucket-pipelines.yml 文件?
【发布时间】:2020-08-21 06:24:15
【问题描述】:

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

我将一个放在分支开发上,另一个放在分支主上,但没有考虑到它们。

【问题讨论】:

    标签: bitbucket bitbucket-pipelines


    【解决方案1】:

    是的,有可能。

    但是,您不需要为每个分支设置不同的文件。您可以根据documentation 为同一文件中的每个分支组织管道。

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

    不要忘记定义默认步骤(这些步骤将针对您之前未定义的每个分支运行)。

    您的 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-06
      • 2021-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 2016-02-08
      相关资源
      最近更新 更多