jenkinsci / jenkinsci/git-plugin

[JENKINS-32521] Strategy: Inverse fails to prevent unwanted builds

Open
#2,793 3 comments 0 reactions 0 assignees View on GitHub
component:git-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

I've two jobs: myproject and myproject-master

The first job is supposed to build all commits that land in master. It does its job admirably. The second job is supposed to build all other branches except master. For that purpose, I configured it as follows:

   "hudson.plugins.git.GitSCM" plugin="git@​2.4.0">

...


master


...


"hudson.plugins.git.util.InverseBuildChooser"/>


...

...

"github@​1.14.0">



false

What happens when I push a branch "foo": myproject-branch builds it.

What happens when I push the master branch: myproject-branch wakes up, fetches upstream changes, then says this:

Seen 98 remote branches

No new revisions were found; the most-recently built branch will be built again.

and proceeds to build an unrelated branch.

What I expect: myproject-branch builds nothing.

---
Originally reported by mgedmin, imported from: Strategy: Inverse fails to prevent unwanted builds


  • status: Open
  • priority: Minor
  • component(s): git-plugin
  • label(s): git-plugin
  • resolution: Unresolved
  • votes: 1
  • watchers: 3
  • imported: 2025-12-02

Raw content of original issue

I've two jobs: myproject and myproject-master

The first job is supposed to build all commits that land in master. It does its job admirably. The second job is supposed to build all other branches except master. For that purpose, I configured it as follows:


   <scm class="hudson.plugins.git.GitSCM" plugin="git@2.4.0">

...
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
...
<extensions>
<hudson.plugins.git.extensions.impl.BuildChooserSetting>
<buildChooser class="hudson.plugins.git.util.InverseBuildChooser"/>
</hudson.plugins.git.extensions.impl.BuildChooserSetting>
</extensions>
...
</scm>
...
<triggers>
<com.cloudbees.jenkins.GitHubPushTrigger plugin="github@1.14.0">
<spec></spec>
</com.cloudbees.jenkins.GitHubPushTrigger>
</triggers>
<concurrentBuild>false</concurrentBuild>

What happens when I push a branch "foo": myproject-branch builds it.

What happens when I push the master branch: myproject-branch wakes up, fetches upstream changes, then says this:



Seen 98 remote branches

No new revisions were found; the most-recently built branch will be built again.


and proceeds to build an unrelated branch.

What I expect: myproject-branch builds nothing.

  • environment: Jenkins 1.644, Git plugin 2.40, Git client plugin 1.19.0, GitHub plugin 1.14.0

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.