Gitlab 触发一个管道并等待它从另一个管道完成

Gitlab 触发一个管道并等待它从另一个管道完成,gitlab,gitlab-ci,Gitlab,Gitlab Ci,我有两个不同的项目存储库:我的应用程序存储库和API存储库。我的应用程序与API通信 我想为我的应用程序设置一些集成和E2E测试。运行这些测试时,应用程序需要使用最新版本的API项目 API项目已设置为在触发时部署 deploy_integration_tests: stage: deploy script: - echo "deploying..." environment: name: integration_testing only: - trigger

我有两个不同的项目存储库:我的应用程序存储库和API存储库。我的应用程序与API通信

我想为我的应用程序设置一些集成和E2E测试。运行这些测试时,应用程序需要使用最新版本的API项目

API项目已设置为在触发时部署

deploy_integration_tests:
  stage: deploy
  script:
  - echo "deploying..."
  environment:
    name: integration_testing
  only:
    - triggers
我的应用程序具有如下设置的集成测试作业:

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..."
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..."
集成测试 阶段:集成测试 脚本: -echo“构建和部署API…” -curl.exe-X POST-F token=-F ref=develope -echo“现在正在运行依赖于API部署的集成测试…” 我遇到的问题是,触发器只对API管道排队(两个项目都使用同一个运行程序),并在API管道实际运行之前继续

在尝试运行集成测试之前,是否有方法等待API管道运行

我可以这样做:

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..."
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..."
integration\u test\u依赖关系
阶段:集成\测试\依赖
脚本:
-echo“构建和部署API…”
-curl.exe-X POST-F token=-F ref=develope
集成测试
阶段:集成测试
脚本:
-echo“现在正在运行依赖于API部署的集成测试…”
但这仍然不能保证API管道在进入集成测试阶段之前运行并完成


有办法做到这一点吗?

目前这是不可能的。gitlab对此存在一些问题:


你最好的办法是重视其中的一些问题。

我错过了完全相同的功能,所以我写了一个python3实用程序来实现它


请参阅。

我最近遇到了这一限制,并设置了一个可重复使用的映像,使其成为一个简单的构建步骤:

因此,在您的情况下,使用“我的图像”会显示如下:

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>
集成测试 阶段:集成测试 图片:registry.gitlab.com/finestucture/pipeline-trigger 脚本: -echo“现在正在运行依赖于API部署的集成测试…” -触发器-a-p 只需使用项目id(而不必查找整个url)并创建一个您在此处提供的个人访问令牌(最好通过秘密进行)

需要后者的原因是为了轮询管道状态。您可以在不使用它的情况下触发,但获得结果需要API授权


请参阅项目说明以了解更多详细信息和pipeline trigger可以做的其他事情。

没有关于此问题的新闻以及是否可能?先生,请告诉我,当我们使用此模块时,我们可以使用一些变量触发pipeline吗?是的,通过
trigger-e foo=条形图
。有关详细信息,请参阅自述文件。