带有`when: manual`的gitlab规则总是被触发

时间:2021-04-30 21:53:59

标签: gitlab-ci

尝试为使用规则为标签自动运行并为特定分支手动运行的作业建模。然而,作业总是在没有用户干预的情况下触发

ismanual:
  stage: prepare
  rules:
    # Always deliver a tagged build
    - if: '$CI_COMMIT_TAG != ""'
      when: on_success
    # Manual deliver a feature branch build
    - if: '$CI_COMMIT_BRANCH =~ /feature\/.*/'
      when: manual
  script:
    - echo "hello"

我正在使用 gitlab.com!

1 个答案:

答案 0 :(得分:0)

您需要更改对提交标签的检查。在规则子句中,您可以检查如下所示的变量,因此无需将其与空字符串进行比较。

ismanual:
  stage: prepare
  rules:
    # Always deliver a tagged build
    - if: '$CI_COMMIT_TAG'
    # Manual deliver a feature branch build
    - if: '$CI_COMMIT_BRANCH =~ /feature\/.*/'
      when: manual
  script:
    - echo "hello"