如何为多个并行作业创建手动触发器

时间:2018-10-04 17:55:59

标签: continuous-integration gitlab gitlab-ci

我想要一个阻止手动操作,它将在下一阶段触发多个并行作业。我该如何实现?例如:

  1. deploy-int在合并中运行
  2. 管道等待单个手动触发
  3. deploy-prd-1和deploy-prd-2并行运行

这是我尝试过的:

1

stages:
  - deploy-dev
  - deploy-prd-1
  - deploy-prd-2

deploy-dev:
  stage: deploy-dev
  script:
    - echo deploy-dev

deploy-prd-1:
  when: manual
  allow_failure: false
  stage: deploy-prd-1
  script:
    - echo deploy-prd-1

deploy-prd-2:
  stage: deploy-prd-2
  script:
    - echo deploy-prd-2

这实现了1和2,但失败了3,因为deploy-prd-1和deploy-prd-2是串联的,而不是并行的

2

stages:
  - deploy-dev
  - deploy-prd

deploy-dev:
  stage: deploy-dev
  script:
    - echo deploy-dev

deploy-prd-1:
  when: manual
  allow_failure: false
  stage: deploy-prd
  script:
    - echo deploy-prd-1

deploy-prd-2:
  stage: deploy-prd
  script:
    - echo deploy-prd-2

此操作在2日失败,因为deploy-prd-2将自动运行,而无需等待手动触发器

3

stages:
  - deploy-dev
  - deploy-prd

deploy-dev:
  stage: deploy-dev
  script:
    - echo deploy-dev

deploy-prd-1:
  when: manual
  allow_failure: false
  stage: deploy-prd
  script:
    - echo deploy-prd-1

deploy-prd-2:
  when: manual
  allow_failure: false
  stage: deploy-prd
  script:
    - echo deploy-prd-2

这不是理想的选择,因为它需要分别手动触发每个并行作业。

4

stages:
  - deploy-dev
  - approve
  - deploy-prd

deploy-dev:
  stage: deploy-dev
  script:
    - echo deploy-dev

approve:
  when: manual
  allow_failure: false

deploy-prd-1:
  stage: deploy-prd
  script:
    - echo deploy-prd-1

deploy-prd-2:
  stage: deploy-prd
  script:
    - echo deploy-prd-2

这是我尝试设置手动“门”的尝试,但是gitlab用Error: jobs:approve script can't be blank拒绝文件。 我可以像script: [":"]这样设置无操作,但是现在gitlab会启动一个容器不做任何事情,这浪费了时间和资源。

0 个答案:

没有答案