I need to selectively run stages in a single .gitlab-ci.yml file, while the selection is done by 1st stage for calling gitlab api.
Below is the simplified code. Finally, only jobs 1, 3, 5, 7, 9 should happen in pipeline:-
.gitlab-ci.yml
:
stages:
- select
- deploy
select-targets:
stage: select
script:
- curl "project_id=$CI_PROJECT_ID" -X POST https://some-api-endpoint
- return some result e.g. [1, 3, 5, 7, 9]
job1:
stage: deploy
script:
- to deploy job 1
only:
- curl return has 1
job2:
stage: deploy
script:
- to deploy job 2
only:
- curl return has 2
job3:
stage: deploy
script:
- to deploy job 3
only:
- curl return has 3
... repeat for job 4 to job 9, now skipped for simplicity
Is this idea possible?