admin管理员组文章数量:1289878
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
- GitLab: v17.3.4-ee
- GitLab Runner, if self-hosted : 16.9.0
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
- GitLab: v17.3.4-ee
- GitLab Runner, if self-hosted : 16.9.0
1 Answer
Reset to default 0Since 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:
- CI_DEFAULT_BRANCH - true for your default branch (develop/main/master)
- CI_OPEN_MERGE_REQUESTS - true if pipeline has open merge request
Please experiment with them.
本文标签: gitlabUse merge request pipeline with code quality stageStack Overflow
版权声明:本文标题:gitlab - Use merge request pipeline with code quality stage - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741430740a2378344.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论