Hi support team,
I’m wondering what our options are if we want to run a pipeline after a merge request is successfully merged or closed.
Looking at the docs I see there’s webhooks, is there another way to approach this?
Thanks,
Uyen Vu
Hi support team,
I’m wondering what our options are if we want to run a pipeline after a merge request is successfully merged or closed.
Looking at the docs I see there’s webhooks, is there another way to approach this?
Thanks,
Uyen Vu
You can define one or more jobs to run after the MR is closed with environment:on_stop
Hi @rpadovani,
Thank you for your suggestion. I am going to try this way.
Update: I have tested with environment:on_stop, it works even more than expectation. Below is all test cases for trigger pipeline (cleanup environment) when environment stop:
Thanks,
Uyen Vu
Hi @rpadovani,
As your answer that we can define one or more jobs to run. However it seems only accept 1 job to run.
For example, I have tried declare as below, error shows that on stop should be a string. Do you have any suggestion on this point?
environment:
on_stop: [job-1,job-2]
Thanks,
Uyen Vu
Hi @uyenvt85
I am happy that you were able to make it working for your use cases.
Unfortunately, it seems my answer was partially wrong: you cannot run multiple jobs in a single on_stop command: https://gitlab.com/gitlab-org/gitlab/-/issues/22456
Hi @rpadovani,
Thank you for your information. I am going to check if there is possible way to do it.
Update: I found a possible way by in the job is declared in on_stop, we could define trigger other jobs (Refer to https://stackoverflow.com/questions/56699829/how-to-trigger-a-specific-job-in-gitlab)
Thank you so much!
Regards,
Uyen Vu
Hi @rpadovani
I have a further question about this topic. is there any way to differentiate merged and closed these two scenarios? I am trying to call different apis when MR closed or merged. Any global variable could be leavaged? Thanks