我想使用GitLab CI和。GitLab - CI。Yml文件使用单独的脚本运行不同的阶段。第一阶段生成一个工具,必须在后面的阶段中使用该工具来执行测试。我已经将生成的工具声明为工件。
现在如何在后期作业中执行该工具呢?正确的路径是什么,它周围会有什么文件?
例如,第一阶段构建工件/bin/TestTool/TestTool.exe,该目录包含其他必需的文件(dll和其他文件)。我的.gitlab-ci。Yml文件是这样的:
releasebuild:
script:
- chcp 65001
- build.cmd
stage: build
artifacts:
paths:
- artifacts/bin/TestTool/
systemtests:
script:
- chcp 65001
- WHAT TO WRITE HERE?
stage: test
构建和测试在Windows上运行(如果相关的话)。
由于默认情况下传递了所有前阶段的工件,我们只需要按正确的顺序定义阶段。请尝试下面的例子,这可能有助于理解。
image: ubuntu:18.04
stages:
- build_stage
- test_stage
- deploy_stage
build:
stage: build_stage
script:
- echo "building..." >> ./build_result.txt
artifacts:
paths:
- build_result.txt
expire_in: 1 week
unit_test:
stage: test_stage
script:
- ls
- cat build_result.txt
- cp build_result.txt unittest_result.txt
- echo "unit testing..." >> ./unittest_result.txt
artifacts:
paths:
- unittest_result.txt
expire_in: 1 week
integration_test:
stage: test_stage
script:
- ls
- cat build_result.txt
- cp build_result.txt integration_test_result.txt
- echo "integration testing..." >> ./integration_test_result.txt
artifacts:
paths:
- integration_test_result.txt
expire_in: 1 week
deploy:
stage: deploy_stage
script:
- ls
- cat build_result.txt
- cat unittest_result.txt
- cat integration_test_result.txt
如果要在不同阶段的作业之间传递工件,我们可以将依赖项与工件一起使用来传递工件,正如文档中所描述的那样。
还有一个更简单的例子:
image: ubuntu:18.04
build:
stage: build
script:
- echo "building..." >> ./result.txt
artifacts:
paths:
- result.txt
expire_in: 1 week
unit_test:
stage: test
script:
- ls
- cat result.txt
- echo "unit testing..." >> ./result.txt
artifacts:
paths:
- result.txt
expire_in: 1 week
deploy:
stage: deploy
script:
- ls
- cat result.txt