How to run a gitlab-ci.yml job only on a tagged branch?

前端 未结 5 1944
不知归路
不知归路 2020-12-23 16:24

How do I run a .gitlab-ci.yml job only on a tagged Master branch?

job:
  script:
  - echo \"Do something\"
  only:
  - master
  - tags

The

5条回答
  •  一生所求
    2020-12-23 16:50

    This behavior will be introduced in version 12.

    Open issue was recently update:

    Jason Lenny @jlenny changed title from {-Update .gitlab-ci.yml to support conjunction logic for build conditions-} to Conjunction logic for build conditions MVC · 2 days ago

    Jason Lenny @jlenny changed milestone to 12.0 · 2 days ago

    (fingers crossed)

    A solution is to use the except keyword to exclude all the branches, in conjunction with only to run on tags, in this way you run your pipeline only on tag in master branch:

      only:
        - tags
      except:
        - branches
    

    I'm using version 11.3.4

提交回复
热议问题