specific 手动作业后如何在 gitlab-ci 中使用规则到 运行

How to use rule in gitlab-ci to run after specific manual job

我有以下几个阶段:

  - run
  - notify

当 运行 有 3 份工作时:run-prod, run-stg, run-dev

所有这些都只能通过手动操作触发,因为它们需要环境变量。

问题是我想 运行 notify 仅当 run 实际上 运行 时(在非手动管道上它不是 运行) - 我该怎么做?

我试过 needsonly 但它不起作用

通知工作:

notify on run success:
  stage: notify
  extends: .dv.notify.slack_channel
  variables:
    SLACK_MESSAGE: "\" Recovery process which triggered by $GITLAB_USER_NAME finished successfully on context: $CONNECT_CONTEXT, connector: $CONNECT_NAME, connectors: $CONNECTORS_NAMES\""
    SLACK_CHANNEL: C02AX03H04F #recovery



notify on run failure:
  stage: notify
  extends: .dv.notify.slack_channel
  variables:
    SLACK_MESSAGE: "\"️ Recovery process which triggered by $GITLAB_USER_NAME failed on context: $CONNECT_CONTEXT, connector: $CONNECT_NAME, connectors: $CONNECTORS_NAMES\""
    SLACK_CHANNEL: C02AX03H04F #recovery

运行-stg:

run-stg:
  extends: run
  script: ...
  rules:
    - if: $CONNECT_CONTEXT =~ /^cs-*/
      when: manual

需要手动输入 CONNECT_CONTEXT 变量的最小示例配置:

stages:
  - run
  - notify

variables:
  CONNECT_CONTEXT:
    description: Your description for this variable.

run:
  stage: run
  rules:
    - if: $CONNECT_CONTEXT =~ /^cs-*/
  script:
    - echo run $CONNECT_CONTEXT

notify:
  stage: notify
  rules:
    - if: $CONNECT_CONTEXT =~ /^cs-*/
  script:
    - echo notify $CONNECT_CONTEXT