我创建了一个 GitLab 自动化 CI/CD 构建流程,如下所示:
该.gitlab-ci.yml
文件如下所示(删除了实际的命令,因为它们对于这个问题并不重要):
stages:
- build
- test
- deploy
build-windows:
stage: build
before_script:
- ...
script:
- ...
artifacts:
paths:
- ...
expire_in: 3 month
tags:
- windows
build-linux-ubuntu:
stage: build
before_script:
- ...
script:
- ...
artifacts:
paths:
- ...
expire_in: 3 month
tags:
- linux
- ubuntu
test-windows:
stage: test
before_script:
- ...
script:
- ...
after_script:
- ...
tags:
- windows
test-linux-ubuntu:
stage: test
before_script:
- ...
after_script:
- ...
tags:
- linux
- ubuntu
deploy-windows:
stage: deploy
before_script:
- ...
script:
- ...
artifacts:
paths:
- ...
after_script:
tags:
- windows
deploy-linux-ubuntu:
stage: deploy
before_script:
- ...
script:
- ...
artifacts:
paths:
- ...
expire_in: 3 month
after_script:
- ...
tags:
- linux
- ubuntu
现在,Linux 的缺点是构建/测试/部署所需的时间比 Windows 更长,因此 Windows 作业完成得更快,只需等待 Linux 作业完成即可。然后,一旦两者都完成,它就会进入下一步。但是,Windows 和 Linux 作业彼此完全独立。
如何让 GitLab 并行构建 Windows 和 Linux,而不产生交叉依赖?像这样: