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

          Jesse Glick added a comment -

          Any particular steps to reproduce? I can try to guess and might get lucky.

          Jesse Glick added a comment - Any particular steps to reproduce? I can try to guess and might get lucky.

          magnayn added a comment -

          Not sure. I may have also seen this behaviour in the non-wf multi branch, where branches seem to have just stopped building.

          I also tried re-running the branch indexing, but didn't seem to help

          magnayn added a comment - Not sure. I may have also seen this behaviour in the non-wf multi branch, where branches seem to have just stopped building. I also tried re-running the branch indexing, but didn't seem to help

          magnayn added a comment -

          Hm. Even more strange behaviour.

          I'd set the 'branches' to be "dev*, release*" - which doesn't work. So I changed it to "dev* release*" - and then when I thought a bit more to just "*".

          Now I have projects building - but I can't access their URL. E.g:
          http://jenkins.blah.com/job/rd2/

          Shows a list of branches. But clicking on one (e.g: dev-main) that's currently building goes to
          http://jenkins.blah.com/job/rd2/branch/dev-main/

          Which results in a 404 Not Found.

          magnayn added a comment - Hm. Even more strange behaviour. I'd set the 'branches' to be "dev*, release*" - which doesn't work. So I changed it to "dev* release*" - and then when I thought a bit more to just "*". Now I have projects building - but I can't access their URL. E.g: http://jenkins.blah.com/job/rd2/ Shows a list of branches. But clicking on one (e.g: dev-main) that's currently building goes to http://jenkins.blah.com/job/rd2/branch/dev-main/ Which results in a 404 Not Found.

          Jesse Glick added a comment -

          The IllegalStateException I have seen (just do not know how to reproduce from scratch yet). The 404 is something else entirely, and I have no guesses what could cause that.

          Jesse Glick added a comment - The IllegalStateException I have seen (just do not know how to reproduce from scratch yet). The 404 is something else entirely, and I have no guesses what could cause that.

          magnayn added a comment -

          Rather helpfully (for me, or unhelpfully for debugging) when I re-started the instance, the 404s went away and it started behaving as normal. :-/

          The original issue also went away - so it looks like some transient issue where manipulating what branches get build and/or rebasing one of them causes a failure that restarting recovers from.

          I will keep monitoring and try to find out if there's a trigger cause.

          magnayn added a comment - Rather helpfully (for me, or unhelpfully for debugging) when I re-started the instance, the 404s went away and it started behaving as normal. :-/ The original issue also went away - so it looks like some transient issue where manipulating what branches get build and/or rebasing one of them causes a failure that restarting recovers from. I will keep monitoring and try to find out if there's a trigger cause.

          Jesse Glick added a comment -

          Thanks, any information will be helpful.

          Jesse Glick added a comment - Thanks, any information will be helpful.

          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: