Gitlab trigger Pipeline only if there is a pushed TAG for all branches except master

一个人想着一个人 提交于 2020-05-13 14:28:32

问题


How does my YAML file have to be configured so that the pipeline for the one case (job: build) is only triggered when a tag is pushed. This tag may be in all branches except master. For the master case I have a separate job (build_master).

yaml file: Problem: If the master branch gets a tag, the pipeline will be run via "build". that should not happen. Nothing should happen

before_script:

  - xcopy /y /s "C:/stuff" "%CI_PROJECT_DIR%"


stages:
  - build
  - deploy





build:
  stage: build
  script:
  - build.cmd
  artifacts:
    expire_in: 1 week
    name: "%CI_COMMIT_REF_NAME%"
    paths:
      - "%CI_COMMIT_REF_NAME%"
  only:
  - tags
  except:
  - master


build_master:
  stage: build
  script:
  - buildm.cmd
  artifacts:
    expire_in: 1 week
    name: "%CI_COMMIT_REF_NAME%"
    paths:
      - "%CI_COMMIT_REF_NAME%"
  only:
  - master

deploy:
 stage: deploy
 script:
 - ./upload.cmd
 dependencies:
 - build_master
 only:
 - master

回答1:


It's not a bug it's a feature.

In Git we do not create tags on branches. This is why this doesn't work. A tag is a reference to a commit / SHA and commit / SHA can exist on multiple branches

gitlab/issues/31305



来源:https://stackoverflow.com/questions/50698370/gitlab-trigger-pipeline-only-if-there-is-a-pushed-tag-for-all-branches-except-ma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!