仅当有新标签时才触发Gitlab-CI管道 [英] Trigger Gitlab-CI Pipeline only when there is a new tag

查看:795
本文介绍了仅当有新标签时才触发Gitlab-CI管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我关注gitlab-ci conf。文件:

I have following gitlab-ci conf. file:

before_script:
  - echo %CI_BUILD_REF%
  - echo %CI_PROJECT_DIR%

stages:
  - createPBLs
  - build
  - package


create PBLs:
  stage: createPBLs
  script: 
    - xcopy /y /s "%CI_PROJECT_DIR%" "C:\Bauen\"
    - cd "C:\Bauen\"
    - ./run_orcascript.cmd


build:
  stage: build
  script:
  - cd "C:\Bauen\"
  - ./run_pbc.cmd
  except:
  - master

build_master:
  stage: build
  script:
  - cd "C:\Bauen\"
  - ./run_pbcm.cmd
  only:
  - master

package:
  stage: package
  script:
  - cd "C:\Bauen\"
  - ./cpfiles.cmd
  artifacts:
    expire_in: 1 week
    name: "%CI_COMMIT_REF_NAME%"
    paths:
      - GitLab-Build

如何添加管道规则仅在将新标签添加到分公司?标签应以 Ticket / ticket_开头。

How can I add the rule that the pipeline will ONLY trigger if a new tag has been added to a branch? The tag should start with "Ticket/ticket_"

当前他正在为每次推送进行构建。

Currently he is building for every push.

推荐答案

我建议在 varibles-expression 中使用提交使用模式

I recommend to use pattern in varibles-expression using commits

示例

build_api:
 stage: build
 script:
  - docker build --pull -t $CONTAINER_TEST_IMAGE .
  - docker push $CONTAINER_TEST_IMAGE
only:
  variables:
   - $CI_COMMIT_MESSAGE =~ /(\[pipeline\]|(merge))/     

这里我说的是,只有 执行 [管道] 或合并。有关更多信息,请参见
gitlab

Here i am saying that only execute that job when have [pipeline] or merge inside the commit. More info, here in gitlab

这篇关于仅当有新标签时才触发Gitlab-CI管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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