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

Workflow multibranch failed after rebase: IllegalStateException: could not find branch tip

      I rebased a branch (dev/main) in git, but the workflow-multibranch poller didn't seem to pick
      it up.

      When I retriggered, I got the following error

      Started by user anonymous
      java.lang.IllegalStateException: could not find branch tip on SCMHead{'dev/main'}
      	at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:91)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:183)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:381)
      Finished: FAILURE
      

          [JENKINS-30798] Workflow multibranch failed after rebase: IllegalStateException: could not find branch tip

          magnayn, Could you try if this PR solves the bug?

          Manuel Recena Soto added a comment - magnayn , Could you try if this PR solves the bug?

          magnayn added a comment - - edited

          I would - but - since I applied a name-correction-hack (below) to multi-branch-workflow and restarting I haven't seen the problem since.. ;-/

          {{
          @@ -42,11 +42,14 @@ public class WorkflowBranchProjectFactory extends BranchProjectFactory<WorkflowJ
          private static final Logger LOGGER = Logger.getLogger(WorkflowBranchProjectFactory.class.getName());

          @DataBoundConstructor public WorkflowBranchProjectFactory() {}

          @Override public WorkflowJob newInstance(Branch branch)

          { - WorkflowJob job = new WorkflowJob((WorkflowMultiBranchProject) getOwner(), branch.getName()); + + String branchName = branch.getName().replace("/", "-"); + + WorkflowJob job = new WorkflowJob((WorkflowMultiBranchProject) getOwner(), branchName); job.setDefinition(new SCMBinder()); setBranch(job, branch); return job; }}

          magnayn added a comment - - edited I would - but - since I applied a name-correction-hack (below) to multi-branch-workflow and restarting I haven't seen the problem since.. ;-/ {{ @@ -42,11 +42,14 @@ public class WorkflowBranchProjectFactory extends BranchProjectFactory<WorkflowJ private static final Logger LOGGER = Logger.getLogger(WorkflowBranchProjectFactory.class.getName()); @DataBoundConstructor public WorkflowBranchProjectFactory() {} @Override public WorkflowJob newInstance(Branch branch) { - WorkflowJob job = new WorkflowJob((WorkflowMultiBranchProject) getOwner(), branch.getName()); + + String branchName = branch.getName().replace("/", "-"); + + WorkflowJob job = new WorkflowJob((WorkflowMultiBranchProject) getOwner(), branchName); job.setDefinition(new SCMBinder()); setBranch(job, branch); return job; }}

          @magnayn Yes, but the bug is still happening. You can reproduce the bug if you do a commit removing Jenkinsfile.

          Manuel Recena Soto added a comment - @magnayn Yes, but the bug is still happening. You can reproduce the bug if you do a commit removing Jenkinsfile .

          magnayn, I've added two new tests, one of them specific for this bug. Your feedback will be nice.

          Manuel Recena Soto added a comment - magnayn , I've added two new tests, one of them specific for this bug. Your feedback will be nice.

          Jesse Glick added a comment -

          recena the exception in that case is more likely one of possibly many side effects of the lack of a fix for JENKINS-30744, so it should probably be ignored.

          Jesse Glick added a comment - recena the exception in that case is more likely one of possibly many side effects of the lack of a fix for JENKINS-30744 , so it should probably be ignored.

          Jesse Glick added a comment -

          JENKINS-30744 is probably one cause, but not the sole one. Have not heard of steps to reproduce with plain branch names. Remember observing it in some cases when manually rebuilding (Build Now) branch projects, apparently worked around by manually triggering branch indexing, but was never able to reproduce it even then.

          Jesse Glick added a comment - JENKINS-30744 is probably one cause, but not the sole one. Have not heard of steps to reproduce with plain branch names. Remember observing it in some cases when manually rebuilding ( Build Now ) branch projects, apparently worked around by manually triggering branch indexing, but was never able to reproduce it even then.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java
          multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinder.java
          multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinderTest.java
          http://jenkins-ci.org/commit/workflow-plugin/1d791a950b927a5bc3ffb18ccda9aca7ebc5d0b4
          Log:
          [FIXED JENKINS-30798] SCMBinder was calling the wrong overload of SCMSource.fetch.
          There is no need to consider SCMSourceCriteria here, nor to inspect unrelated branches.
          It was also not dealing gracefully with problems such as deleted branches.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinder.java multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinderTest.java http://jenkins-ci.org/commit/workflow-plugin/1d791a950b927a5bc3ffb18ccda9aca7ebc5d0b4 Log: [FIXED JENKINS-30798] SCMBinder was calling the wrong overload of SCMSource.fetch. There is no need to consider SCMSourceCriteria here, nor to inspect unrelated branches. It was also not dealing gracefully with problems such as deleted branches.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java
          multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinder.java
          multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinderTest.java
          http://jenkins-ci.org/commit/workflow-plugin/85553288ab80ad69ded0df1db3ec77bb89fd12f0
          Log:
          Merge pull request #235 from jglick/SCMBinder-fetch

          JENKINS-30798 SCMBinder was calling the wrong overload of SCMSource.fetch

          Compare: https://github.com/jenkinsci/workflow-plugin/compare/00c8c62d5276...85553288ab80

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinder.java multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinderTest.java http://jenkins-ci.org/commit/workflow-plugin/85553288ab80ad69ded0df1db3ec77bb89fd12f0 Log: Merge pull request #235 from jglick/SCMBinder-fetch JENKINS-30798 SCMBinder was calling the wrong overload of SCMSource.fetch Compare: https://github.com/jenkinsci/workflow-plugin/compare/00c8c62d5276...85553288ab80

          Code changed in jenkins
          User: Jesse Glick
          Path:
          cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/85f555b1773e15213b4772e33f2207350aae90b6
          Log:
          [FIXED JENKINS-30798] SCMBinder was calling the wrong overload of SCMSource.fetch.
          There is no need to consider SCMSourceCriteria here, nor to inspect unrelated branches.
          It was also not dealing gracefully with problems such as deleted branches.
          Originally-Committed-As: 1d791a950b927a5bc3ffb18ccda9aca7ebc5d0b4

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsScmFlowDefinition.java http://jenkins-ci.org/commit/workflow-cps-plugin/85f555b1773e15213b4772e33f2207350aae90b6 Log: [FIXED JENKINS-30798] SCMBinder was calling the wrong overload of SCMSource.fetch. There is no need to consider SCMSourceCriteria here, nor to inspect unrelated branches. It was also not dealing gracefully with problems such as deleted branches. Originally-Committed-As: 1d791a950b927a5bc3ffb18ccda9aca7ebc5d0b4

          Code changed in jenkins
          User: Jesse Glick
          Path:
          multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinder.java
          multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinderTest.java
          http://jenkins-ci.org/commit/workflow-multibranch-plugin/f19ab8f9d5d9b3ac889abfcd412dfad5332fb542
          Log:
          [FIXED JENKINS-30798] SCMBinder was calling the wrong overload of SCMSource.fetch.
          There is no need to consider SCMSourceCriteria here, nor to inspect unrelated branches.
          It was also not dealing gracefully with problems such as deleted branches.
          Originally-Committed-As: 1d791a950b927a5bc3ffb18ccda9aca7ebc5d0b4

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinder.java multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/SCMBinderTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/f19ab8f9d5d9b3ac889abfcd412dfad5332fb542 Log: [FIXED JENKINS-30798] SCMBinder was calling the wrong overload of SCMSource.fetch. There is no need to consider SCMSourceCriteria here, nor to inspect unrelated branches. It was also not dealing gracefully with problems such as deleted branches. Originally-Committed-As: 1d791a950b927a5bc3ffb18ccda9aca7ebc5d0b4

            recena Manuel Recena Soto
            magnayn magnayn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: