Starting a pipeline and waiting for it to complete from another pipeline

I have two different project repositories: my application repository and the API repository. My application communicates with the API.

I want to configure the integration and E2E tests of my application. When performing these tests, the application will need to use the latest version of the API project.

API project is already configured for deployment at startup

deploy_integration_tests: stage: deploy script: - echo "deploying..." environment: name: integration_testing only: - triggers 

My application has an integration testing task configured as follows:

 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..." 

The problem I ran into is that the trigger only terminates the API pipeline (both projects use the same runner) and continue until the API pipeline actually starts.

Is there a way to wait for the API pipeline to complete before trying to run the integration test?

I can do something like this:

 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..." 

But this does not mean that the API pipeline works and ends before moving on to the integration_test stage.

Is there any way to do this?

+5
source share
3 answers

This is currently not possible. There are some issues with gitlab:

It is best to give weight to some of these problems.

+2
source

I lacked the same function, so I wrote a python3 program for it.

See Python Commander on GitHub .

+1
source

I recently met this limitation and created an image that can be reused to make this simple build step:

https://gitlab.com/finestructure/pipeline-trigger

So, in your case, it will look like this using my image:

 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> 

Just use the project identifier (instead of finding the whole URL) and create the access token that you provide here (best of all, do it with a secret).

The reason the latter is needed is to poll the status of the pipeline. You can run without it, but getting the result requires API authorization.

0
source

Source: https://habr.com/ru/post/1268490/


All Articles