Skip to content

Inconsistent "Only Branches that are filed as MRs" branch filtering #761

Description

@hcorg

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):

                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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions