08-rules
You may probably control if a job is executed when pushing on the master
branch, or when updating a merge request.
For this, you can use rules.
TODO
-
create a merge request from this issue -
open the WebIDE -
update the .gitlab-ci.yml
file -
add a new stage: all_under_control
-
add a new job: when_master
belonging toall_under_control
when_master: stage: all_under_control tags: [docker] rules: - if: $CI_COMMIT_BRANCH == "master" # 1️⃣ script: | echo "We are on the master branch"
1️⃣ we test if we are pushing on themaster
branch, and if yes, the job will be triggered -
add a new job: when_merge_request
belonging toall_under_control
when_merge_request: stage: all_under_control tags: [docker] rules: - if: $CI_MERGE_REQUEST_IID # 1️⃣ script: | echo "We are on the branch $CI_COMMIT_REF_NAME" echo "IID: $CI_MERGE_REQUEST_IID"
1️⃣ we test if we are doing a merge request, and if yes, the job will be triggered -
commit your changes, it will trigger the pipeline -
observe the pipeline (how many jobs in the all_under_control
stage ?) -
observe the output of the pipeline -
merge on master (the pipe will be triggered again) -
observe the pipeline (and output) again