我有两个不同的项目存储库:我的应用程序存储库和API存储库.我的应用程序与API通信.
我想为我的应用程序设置一些集成和E2E测试.运行这些测试时,应用程序将需要使用最新版本的API项目.
API项目已设置为在触发时进行部署
deploy_integration_tests:
stage: deploy
script:
- echo "deploying..."
environment:
name: integration_testing
only:
- triggers
Run Code Online (Sandbox Code Playgroud)
我的应用程序有一个集成测试工作设置如下:
integration_test
stage: integration_test
script:
- echo "Building and deploying API..."
- curl.exe -X POST -F token=<token> -F ref=develop <url_for_api_trigger>
- echo "Now running the integration test that depends on the API deployment..."
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是触发器只排队API管道(两个项目都使用相同的运行程序)并在API管道实际运行之前继续.
有没有办法在尝试运行集成测试之前等待API管道运行?
我可以这样做:
integration_test_dependency
stage: integration_test_dependency
script:
- echo "Building and deploying API..."
- curl.exe -X POST -F token=<token> -F ref=develop <url_for_api_trigger>
integration_test
stage: integration_test
script:
- echo "Now running the integration test that depends on the API deployment..."
Run Code Online (Sandbox Code Playgroud)
但是,在继续进入integration_test阶段之前,仍然没有承认API管道运行并完成.
有没有办法做到这一点?
end*_*and 12
如果其他人在 ci yaml 的触发管道上寻找此内容,您可以使用关键字dependforstrategy来确保管道等待触发管道:
trigger:
project: group/triggered-repo
strategy: depend
Run Code Online (Sandbox Code Playgroud)
我最近遇到了这个限制,并设置了可以重新使用的映像,以使其成为简单的构建步骤:
https://gitlab.com/finestructure/pipeline-trigger
因此,在您的情况下,使用我的图片看起来像这样:
integration_test
stage: integration_test
image: registry.gitlab.com/finestructure/pipeline-trigger
script:
- echo "Now running the integration test that depends on the API deployment..."
- trigger -a <api token> -p <token> <project id>
Run Code Online (Sandbox Code Playgroud)
只需使用项目ID(而不是查找整个URL)并创建一个个人访问令牌即可,您可以在此处提供该令牌(最好通过秘密来完成此操作)。
需要后者的原因是用于轮询管道状态。您可以在没有触发的情况下进行触发,但要获得结果需要API授权。
请参阅项目描述,以获取更多详细信息以及管道触发可以执行的其他操作。
目前这是不可能的。gitlab 中有一些关于此的问题:
最好的选择是重视其中一些问题。
| 归档时间: |
|
| 查看次数: |
5387 次 |
| 最近记录: |