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

InterruptedException during initial checkout leads to FAILURE instead of ABORT

      An aborted build should have the status ABORTED. The status is FAILURE if the build gets aborted during the initial checkout. An interrupted exception should be handled gracefully and lead to ABORTED (also no repeats of the checkout should be triggered).

      I came across this issue while working on JENKINS-72819. Here the InterruptedException is causing a NPE in the exception handler in the git-client-plugin. After fixing this issue I now get the following call stack in case of an early abort. The last line is saying FAILURE which should be ABORTED.
       
      ERROR: Checkout failed
      java.lang.InterruptedException
      at java.base/java.lang.Object.wait(Native Method)
      at java.base/java.lang.Object.wait(Unknown Source)
      at java.base/java.lang.ProcessImpl.waitFor(Unknown Source)
      at hudson.Proc$LocalProc.join(Proc.java:328)
      at hudson.Proc.joinWithTimeout(Proc.java:172)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2839)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635)
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:871)
      at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1222)
      at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
      at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:165)
      at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:71)
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:311)
      at hudson.model.ResourceController.execute(ResourceController.java:101)
      at hudson.model.Executor.run(Executor.java:442)
      ERROR: Maximum checkout retry attempts reached, aborting
      Finished: FAILURE
       
       

          [JENKINS-72830] InterruptedException during initial checkout leads to FAILURE instead of ABORT

          Christoph Kulla added a comment - - edited

          I figured out two places causing this behaviour:

          1.  worklfow-cps plugin: In CpsScmFlowDefinition an InterruptedException must be rethrown instead of causing a repeat (and then causing a failure if max repeats is 1)
          2. workflow-job. plugin: The exception handler in WorkflowRun.run() should recognize an InterruptedException, the test for Thread.interrupted() fails here, unclear why. The job is aborted with WorfklowRun.doStop())

          jglick Why is Thread.interrupted() not returning true here? I can provide PRs for these two points if this all makes sense to you.

          Christoph Kulla added a comment - - edited I figured out two places causing this behaviour:  worklfow-cps plugin: In CpsScmFlowDefinition an InterruptedException must be rethrown instead of causing a repeat (and then causing a failure if max repeats is 1) workflow-job. plugin: The exception handler in WorkflowRun.run() should recognize an InterruptedException, the test for Thread.interrupted() fails here, unclear why. The job is aborted with WorfklowRun.doStop()) jglick Why is Thread.interrupted() not returning true here? I can provide PRs for these two points if this all makes sense to you.

          Jesse Glick added a comment -

          We do not generally use Thread.interrupted; it is too complicated to use correctly. I am not familiar with the JENKINS-46961 fix.

          Jesse Glick added a comment - We do not generally use Thread.interrupted ; it is too complicated to use correctly. I am not familiar with the JENKINS-46961 fix.

            Unassigned Unassigned
            ckullabosch Christoph Kulla
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: