Reputation: 567
I want to run tests and code quality pipelines and see results on merge request reports/widgets. The problem is that code quality is showing difference between source and target branch artifacts.
So when I use rule like: if: $CI_PIPELINE_SOURCE == "merge_request_event"
, it is running merge request pipeline and code quality widget is not working in merge request view.
Is it possible to somehow setup rules, to run branch pipeline only for MR and for default branch? I don't want to run this pipeline for push when there is no merge request.
The best configuration I could figure out is below, but this pipeline is not starting when I first push branch and then open MR.
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_REF_NAME && $CI_OPEN_MERGE_REQUESTS
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
Or maybe there is another way to assign merge request artifact to branch?
Versions
Upvotes: 0
Views: 32
Reputation: 46
Since there are not many details about your code quality process, I will focus on your question:
Is it possible to somehow setup rules, to run branch pipeline only for MR and for default branch?
I think job rules may be something like this:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: always
- when: never
This set of rules uses GitLab environment variables like:
Please experiment with them.
Upvotes: 0