Reputation: 71
I wanna run pipeline only when someone commits into master or merges branch into master. have such a code:
commit_to_master_notification:
stage: build
script:
- echo "rest of script"
only:
refs:
- master
but when I just triger pipeline on master branch this job is stared. How to change it to start it only when someone commits into master or after merging code.
Upvotes: 0
Views: 1262
Reputation: 1328712
You can start testing with if rules
, using predefined variables:
job:
script: echo "Only for master commits or merge"
rules:
- if $CI_COMMIT_BRANCH == "master"' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
...
Upvotes: 2