Saya pikir itu dapat dilaksanakan melalui needs
dan resource_group
kata kunci dan gitlab API.
Setiap pekerjaan menerima id pipa yang menjadi miliknya predefined-variable
. Jika Anda menggunakan api gitlab, Anda dapat melihat status pekerjaan lain di dalam pipa. Jika Anda dapat menggunakan status ini, needs
dan resource_group
kata kunci saya pikir Anda dapat mencapai apa yang Anda inginkan. Lihat deskripsi kode di bawah ini dan komentarnya untuk lebih jelasnya.
stages:
- ready
- build
job1:
stage: build
needs: [starting_signal]
script:
- sleep 10 && echo "job1"
job2:
stage: build
needs: [starting_signal]
script:
- sleep 20 && echo "job2"
job3:
stage: build
needs: [starting_signal]
script:
- sleep 30 && echo "job3"
starting_signal:
stage: ready
script:
- # TODO: You need to implement it using the GitLab API.
- # The starting condition for "job1-3" is
- # that this `starting_signal` job finished successfully.
- # And the condition that ends with the success of this job
- # is that `traffic_light` becomes running.
traffic_light:
stage: ready
resource_group: traffic_light
script:
- # TODO: You need to implement it using the GitLab API.
- # The end condition for `traffic_light` is
- # the end of job1-3 execution.
- # In other words, this job must be checked and waited
- # through gitlab api until job 1,2,3 is finished.
- # Since this job locks the execution of a `traffic_light` job
- # in another pipeline, the `starting_signal` job in another
- # pipeline does not succeed.
(Saya tidak mengujinya sendiri, jadi metode ini perlu ditinjau.)
Referenecs: