jenkinsci / jenkinsci/gitlab-branch-source-plugin
Inconsistent "Only Branches that are filed as MRs" branch filtering
- Dominant language
- Java
- Stars
- 134
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
When this strategy is selected, the branch are being built or not depending on _number of open MRs_.
When there is a single MR - the branch associated with that MR is also built. When there are more MRs - branch is filtered out.
I think the root cause lays in OnlyOriginMRBranchesSCMHeadFilter.isExcluded (BranchDiscoveryTrait.java):
```java
for (MergeRequest m : ((GitLabSCMSourceRequest) request).getMergeRequests()) {
if (m.getSourceProjectId().equals(m.getTargetProjectId())
&& !m.getSourceBranch().equalsIgnoreCase(head.getName())) {
return true;
}
```
This excludes branch _if there is a MR that does *not* have it as source_. So with single MR the branch is not excluded, two MR and branch is excluded.
Maybe this is the "legacy" behaviour that Strategy help hint refer to, but it is highly surprising to the user. Maybe it should be either documented or fixed (I can prepare PR for that, but I don't know what is the best approach assuming this "legacy" might be required for backward compatibility).
What I'd need is ability to build: "master" _and_ MRs. No branches that are not filled as MR. Current option works as long as I have at least two MRs... Is adding another strategy an option? (I'll prepare the PR)
Contributor guide
Assessment
This issue has not been assessed yet.