只有在除master以外的所有分支都有TAG推送的情况下,Gitlab才会触发Pipeline [英] Gitlab trigger Pipeline only if there is a pushed TAG for all branches except master

查看:695
本文介绍了只有在除master以外的所有分支都有TAG推送的情况下,Gitlab才会触发Pipeline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何配置我的YAML文件,以便仅在按下标签时才触发一种情况(作业:构建)的管道.该标签可能在除master之外的所有分支中.对于大案例,我有一个单独的工作(build_master).

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文件: 问题:如果master分支获得标签,则管道将通过"build"运行.那不应该发生.什么都不会发生

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

推荐答案

这不是bug,而是功能.

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

在Git中,我们不在分支上创建标签.这就是为什么这行不通的原因.标签是对commit/SHA的引用,并且commit/SHA可以存在于多个分支中

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

这篇关于只有在除master以外的所有分支都有TAG推送的情况下,Gitlab才会触发Pipeline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆