Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45049

Git plugin still defaults to run on all branches

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • git-plugin
    • None

      This was originally reported here and marked as fixed: 

      https://issues.jenkins-ci.org/browse/JENKINS-18820?jql=text%20~%20%22default%20branch%22

       

      However, the fix only seems to change the textbox: 

      https://github.com/jenkinsci/git-plugin/commit/7758cde84d261403f6c8a31097544c8cc6792471

       

      It doesn't fix the underlying behavior that the default shouldn't build all branches.

       

      Looking at https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitSCM.java it seems like this was tried on line 175:

       

      this.branches = isEmpty(branches) ? newArrayList(new BranchSpec("*/master")) : branches;
       
      

       

      However, the Constructor is called on line 155 with a list of one item:

       

       

      public GitSCM(String repositoryUrl) {
      this(
      createRepoList(repositoryUrl, null),
      Collections.singletonList(new BranchSpec("")),
      false, Collections.<SubmoduleConfig>emptyList(),
      null, null, Collections.<GitSCMExtension>emptyList());
      }

       

       

      Since this is a list of one item I think it passes the isEmpty() check and still defaults to building all branches instead of */master.

       

      This recently caused a lot of pain, when someone accidentally did a build with parameters and didn't specify a branch. It then built every branch on origin overloading our build server.

       

       

      I briefly tried to checkout the project to submit a pull request, but I couldn't get the project to build because of this error:

       

      Gradle sync failed: Could not find org.jenkins-ci.tools:gradle-jpi-plugin:0.1-SNAPSHOT.
       Searched in the following locations:
       https://repo1.maven.org/maven2/org/jenkins-ci/tools/gradle-jpi-plugin/0.1-SNAPSHOT/maven-metadata.xml
       https://repo1.maven.org/maven2/org/jenkins-ci/tools/gradle-jpi-plugin/0.1-SNAPSHOT/gradle-jpi-plugin-0.1-SNAPSHOT.pom
       https://repo1.maven.org/maven2/org/jenkins-ci/tools/gradle-jpi-plugin/0.1-SNAPSHOT/gradle-jpi-plugin-0.1-SNAPSHOT.jar
       file:/Users/djbrick/.m2/repository/org/jenkins-ci/tools/gradle-jpi-plugin/0.1-SNAPSHOT/maven-metadata.xml
       file:/Users/djbrick/.m2/repository/org/jenkins-ci/tools/gradle-jpi-plugin/0.1-SNAPSHOT/gradle-jpi-plugin-0.1-SNAPSHOT.pom
       file:/Users/djbrick/.m2/repository/org/jenkins-ci/tools/gradle-jpi-plugin/0.1-SNAPSHOT/gradle-jpi-plugin-0.1-SNAPSHOT.jar
       Required by:
       :git-plugin:unspecified
       Consult IDE log for more details (Help | Show Log)

       

            Unassigned Unassigned
            djbrick David Brick
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: