I want to run Job only for merge_requests refs AND when changes for specified files, according to official doc i create this Job in .gitlab-ci.yml:
merge-request-test:
<<: *some_anchor
only:
refs:
- merge_requests
changes:
- "*.py"
- "**/*.py"
- postman/some-file.json
But this job starts even if i change any other file.
I understand that GitLab CI apply OR rule for refs and changes sections:
In the example below, the test job will not be created when any of the following are true:
The pipeline runs for the master. There are changes to the README.md file in the root directory of the repo.
test: script: npm run test except: refs: - master changes: - "README.md"
I want to start this Job only for MR and when changes specified files. How i can achieve this behaviour?
If remove refs section, it works only when files changed, but official doc does not recommend do this, because i want to use it in pipelines:
If using only:changes with only allow merge requests to be merged if the pipeline succeeds, undesired behavior could result if you do not also use only:merge_requests.