在GitLab CI部署管道中进行手动批准

时间:2019-10-11 09:33:14

标签: gitlab gitlab-ci

我们有一个 GitLab CI 构建/测试/部署管道,并且需要在 Test 的部署和升级之间插入人工批准产品。我不知道该怎么做。

理想情况下,我们希望有一个类似 GoCD AWS CodePipeline 中的按钮。但是,对于我们当前的项目,我们使用托管在服务器上的 GitLab EE (版本12.3.5-ee),而不是使用gitlab.com,但我猜.gitlab-ci.yml应该是相同的。 / p>

这是我当前的.gitlab-ci.yml的一部分:

stages:
  # lint, build, test, ...
  - deploy_test
  - approval
  - deploy_prod


deploy_test:
  stage: deploy_test
  only:
    refs:
      - prod

  script:
    ...

wait_for_approval:
  stage: approval
  # how do I do this???

deploy_prod:
  stage: deploy_prod
  only:
    refs:
      - prod

  script:
    ...

有什么主意吗?

1 个答案:

答案 0 :(得分:1)

在您的舞台中使用import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Test{ public static int matrix[][]; public static void main(String[] args) { borderLayout(5, 5); print(); } public static void borderLayout(int rows, int columns) { //create a list (1,3,5, ...) with size = columns - 1 List<Integer> list = IntStream.iterate(1, i -> i + 2) .limit(columns - 1).boxed() .collect(Collectors.toList()); matrix = new int[rows][columns]; int square = Math.min(rows, columns); for (int i = 0; i < square; i++) { int temp = (i + 1) * (i + 1); for (int j = 0; j < square; j++) { if (j == 0) { matrix[i][j] = temp; } else { matrix[i][j] = matrix[i][j - 1] + list.get(j - 1); } } if (i < columns - 1) { list.set(i, -1); } } if (rows > columns) { int counter = (int) Math.pow(Math.min(rows, columns), 2); int sqrt = (int) Math.sqrt(counter); for (int i = sqrt; i < rows; i++) { for (int j = 0; j < columns; j++) { matrix[i][j] = ++counter; } } } else if (rows < columns) { int counter = (int) Math.pow(Math.min(rows, columns), 2); int sqrt = (int) Math.sqrt(counter); for (int i = sqrt; i < columns; i++) { for (int j = 0; j < rows; j++) { matrix[j][i] = ++counter; } } } } private static void print() { for (int[] row : matrix) { for (int i : row) { System.out.printf("%4d ", i); } System.out.println(); } } }

为确保手动操作被阻止(并且没有选项),请同时添加when: manual(默认情况下设置为allow_failure: false

documentation

中的更多信息

注意:如果您仅创建批准阶段,我建议您删除该阶段并将true置于when: manual阶段。