jenkinsci / jenkinsci/github-branch-source-plugin

[JENKINS-68151] Branch strategies not working with Behaviors

Open
#1,390 0 comments 0 reactions 0 assignees View on GitHub
component:github-branch-source-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
217
Forks
398
Avg merge
30m
Merged PRs (30d)
1

Description

We have a Multi-Branch Pipeline job for our GitHub project where we would like for the job to only be triggered for a couple of named branches and all Pull Requests.

Unfortunately, no matter what we do, we are triggering builds for all branches and all PRs.  There are several negative side-effects of this but one is that all PRs end up with two builds attached to them (one for the branch which is triggered when the branch is pushed and one for the PR when it is created from the branch).

We have the following settings in the github-branch-source-plugin:

Behavior:



  • Discover branches: Exclude branches that are also filed as PRs

  • Discover pull requests from origin: Merging the pull request...

  • Discover pull requests from forks:  Merging the pull request...

Property strategy: All branches get the same properties

Build strategies:



  • Change Requests

  • Named Branches

    • Names

      • Exact match: main

      • Exact match: release/3.3

      • Exact match: release/3.4





Have we misunderstood the configuration needed to achieve this goal or is it not possible without polluting our Jenkinsfile with where blocks for each stage to disable each stage for unwanted branches?

 

---
Originally reported by rhpatrick, imported from: Branch strategies not working with Behaviors


  • status: Open
  • priority: Major
  • component(s): github-branch-source-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-02

Raw content of original issue

We have a Multi-Branch Pipeline job for our GitHub project where we would like for the job to only be triggered for a couple of named branches and all Pull Requests.

Unfortunately, no matter what we do, we are triggering builds for all branches and all PRs.  There are several negative side-effects of this but one is that all PRs end up with two builds attached to them (one for the branch which is triggered when the branch is pushed and one for the PR when it is created from the branch).

We have the following settings in the github-branch-source-plugin:

Behavior:



  • Discover branches: Exclude branches that are also filed as PRs

  • Discover pull requests from origin: Merging the pull request...

  • Discover pull requests from forks:  Merging the pull request...

Property strategy: All branches get the same properties

Build strategies:



  • Change Requests

  • Named Branches

    • Names

      • Exact match: main

      • Exact match: release/3.3

      • Exact match: release/3.4





Have we misunderstood the configuration needed to achieve this goal or is it not possible without polluting our Jenkinsfile with where blocks for each stage to disable each stage for unwanted branches?

 

  • environment: Jenkins 2.332.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.