Here are behavior of the job I needed. This is considered as previous job, as the second job run condition will depend on this job. My previous job will run on these condition.
- if it is on schedule or develop branch, run this job automatically
- if it is a merge request with file change under docker directory, run this automatically
- if it is a merge request without file change under docker directory, manual run (this job is optional)
it_build: stage: build rules: - if: $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "develop" - if: $CI_PIPELINE_SOURCE == "merge_request_event" changes: - docker/* - if: $CI_PIPELINE_SOURCE == "merge_request_event" when: manual
This job will build images and push to registry. There will be a schedule run every day to update images. If there is some change in docker script, that merge request will also run this job too, or developer can run it manually as well if needed. With this assume that images always in registry and ready to be pulled. So this job is not need to run in merge request.
Then I have another job that will pull these images publish by the above job (it_build).
Is it possible for this second job to have condition like these for a merge request
If it_build is being run automatically because some file change under docker directory, wait for this job to finish before run another job.
If it_build is NOT run automatically and developer trigger it_build manually, wait for this job to finish before run another job.
If it_build is NOT run automatically and developer also NOT trigger it_build manually, another job run automatically.
It will be simple if I have only condition 1 and condition 2, but with additional of condition 3 I have no idea.