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

Origin branches disappear when there is a fork with the same branch name

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Steps to recreate:

      1. Create a fork of a GitHub repo (in this example, originalRepo). Do not create a GitHub Branch Source multibranch project for this yet.
      2. In this new fork, make changes in your master branch. (Actually, any branch will probably do, I just picked master)
      3. Push the change to your newly-created fork.
      4. Create a PR from your fork/master, to the original repo/master.

      5. Now, create your multibranch project for originalRepo. Make sure that the Discover Branches strategy is set to the default of Only branches that are not also filed as PRs.

      6. Examine the Scan Repository log. You'll see something like this:

      Examining cloudbees/quality-assurance
        Checking branches...
        Getting remote branches...
          Checking branch master
        Getting remote pull requests...
      

      Notice that there's no Met Criteria or Does not Meet Criteria message. This is a tell.

      7. Go back to the top of your project for originalRepo. There's no master branch shown.

      8. In GitHub, merge (or merge/close) the PR.
      9. Rescan.
      10. The master branch will appear.

        Attachments

        1. screenshot-1.png
          screenshot-1.png
          515 kB
        2. screenshot-2.png
          screenshot-2.png
          546 kB
        3. screenshot-3.png
          screenshot-3.png
          653 kB
        4. screenshot-4.png
          screenshot-4.png
          653 kB
        5. screenshot-5.png
          screenshot-5.png
          525 kB
        6. screenshot-6.png
          screenshot-6.png
          555 kB

          Issue Links

            Activity

            Hide
            kshultz Karl Shultz added a comment -

            I built the PR myself and uploaded it to my test instance. Following the same steps, I'm seeing the scan throw a NPE:

            Started by user admin
            [Fri Jul 14 19:54:06 UTC 2017] Starting branch indexing...
            19:54:07 Connecting to https://api.github.com using kshultzCB/****** (kshultzCB with token global)
            19:54:07 Connecting to https://api.github.com using kshultzCB/****** (kshultzCB with token global)
            Examining cloudbees/quality-assurance
            
              Checking branches...
            
              Getting remote branches...
            
                Checking branch master
            
              Getting remote pull requests...
            ERROR: [Fri Jul 14 19:54:07 UTC 2017] Could not fetch branches from source 3ab1bc77-e2f8-4275-9dd2-781a530fc1ef
            java.lang.NullPointerException
            	at org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait$ExcludeOriginPRBranchesSCMHeadFilter.isExcluded(BranchDiscoveryTrait.java:236)
            	at jenkins.scm.api.trait.SCMSourceRequest.isExcluded(SCMSourceRequest.java:198)
            	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:335)
            	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:251)
            	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:865)
            	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:355)
            	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:265)
            	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:630)
            	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:266)
            	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:162)
            	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:969)
            	at hudson.model.ResourceController.execute(ResourceController.java:97)
            	at hudson.model.Executor.run(Executor.java:415)
            [Fri Jul 14 19:54:07 UTC 2017] Finished branch indexing. Indexing took 0.42 sec
            FATAL: Failed to recompute children of JENKINS-45551--After
            java.lang.NullPointerException
            	at org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait$ExcludeOriginPRBranchesSCMHeadFilter.isExcluded(BranchDiscoveryTrait.java:236)
            	at jenkins.scm.api.trait.SCMSourceRequest.isExcluded(SCMSourceRequest.java:198)
            	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:335)
            	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:251)
            	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:865)
            	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:355)
            	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:265)
            	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:630)
            	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:266)
            	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:162)
            	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:969)
            	at hudson.model.ResourceController.execute(ResourceController.java:97)
            	at hudson.model.Executor.run(Executor.java:415)
            Finished: FAILURE
            
            Show
            kshultz Karl Shultz added a comment - I built the PR myself and uploaded it to my test instance. Following the same steps, I'm seeing the scan throw a NPE: Started by user admin [Fri Jul 14 19:54:06 UTC 2017] Starting branch indexing... 19:54:07 Connecting to https://api.github.com using kshultzCB/****** (kshultzCB with token global) 19:54:07 Connecting to https://api.github.com using kshultzCB/****** (kshultzCB with token global) Examining cloudbees/quality-assurance Checking branches... Getting remote branches... Checking branch master Getting remote pull requests... ERROR: [Fri Jul 14 19:54:07 UTC 2017] Could not fetch branches from source 3ab1bc77-e2f8-4275-9dd2-781a530fc1ef java.lang.NullPointerException at org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait$ExcludeOriginPRBranchesSCMHeadFilter.isExcluded(BranchDiscoveryTrait.java:236) at jenkins.scm.api.trait.SCMSourceRequest.isExcluded(SCMSourceRequest.java:198) at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:335) at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:251) at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:865) at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:355) at jenkins.scm.api.SCMSource.fetch(SCMSource.java:265) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:630) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:266) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:162) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:969) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:415) [Fri Jul 14 19:54:07 UTC 2017] Finished branch indexing. Indexing took 0.42 sec FATAL: Failed to recompute children of JENKINS-45551--After java.lang.NullPointerException at org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait$ExcludeOriginPRBranchesSCMHeadFilter.isExcluded(BranchDiscoveryTrait.java:236) at jenkins.scm.api.trait.SCMSourceRequest.isExcluded(SCMSourceRequest.java:198) at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:335) at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:251) at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:865) at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:355) at jenkins.scm.api.SCMSource.fetch(SCMSource.java:265) at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:630) at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:266) at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:162) at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:969) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:415) Finished: FAILURE
            Hide
            kshultz Karl Shultz added a comment -

            As a final experiment, I downgraded back to beta-2, and the NPE went away.

            Show
            kshultz Karl Shultz added a comment - As a final experiment, I downgraded back to beta-2, and the NPE went away.
            Hide
            stephenconnolly Stephen Connolly added a comment -
            Show
            stephenconnolly Stephen Connolly added a comment - Karl Shultz Found the root cause of the NPE, https://github.com/cloudbees/quality-assurance/pull/12  is from a deleted fork, so the head repository is null. https://github.com/jenkinsci/github-branch-source-plugin/pull/147/commits/99cf637dac65c5db6d7f378515d0687f222d8543  fixes the NPE
            Hide
            kshultz Karl Shultz added a comment -

            I built the plugin again and retraced my steps. There are no disappearing branches. There is also no longer an NPE when the PR is from a fork which has been deleted before doing the merge. I believe this issue to have been resolved with Stephen's changes.

            Show
            kshultz Karl Shultz added a comment - I built the plugin again and retraced my steps. There are no disappearing branches. There is also no longer an NPE when the PR is from a fork which has been deleted before doing the merge. I believe this issue to have been resolved with Stephen's changes.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Stephen Connolly
            Path:
            src/main/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTrait.java
            http://jenkins-ci.org/commit/github-branch-source-plugin/26a8b395e0ac2cf404f4f68b9a447b4e465035bc
            Log:
            [FIXED JENKINS-45551] The TODO comments were correct

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stephen Connolly Path: src/main/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTrait.java http://jenkins-ci.org/commit/github-branch-source-plugin/26a8b395e0ac2cf404f4f68b9a447b4e465035bc Log: [FIXED JENKINS-45551] The TODO comments were correct
            Hide
            stephenconnolly Stephen Connolly added a comment -

            2.2.0

            Show
            stephenconnolly Stephen Connolly added a comment - 2.2.0

              People

              • Assignee:
                stephenconnolly Stephen Connolly
                Reporter:
                stephenconnolly Stephen Connolly
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: