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

safeRestart() causing no loaded shell in CpsFlowExecution exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: pipeline, safe-restart
    • Environment:
    • Similar Issues:

      Description

       

      We have encountered a repeatable issue where if we execute a doSafeRestart() or safeRestart() within an imperative or declarative pipeline, Jenkins throws the following error after it restarts and tries to resume the job (even though there is nothing left to do).  

       

      Pausing (Preparing for shutdown)
      Resuming build at Fri Oct 23 10:00:49 EDT 2020 after Jenkins restart
      [Pipeline] End of Pipeline
      java.lang.IllegalStateException: JENKINS-50407: no loaded shell in CpsFlowExecution[Owner[restart/112:restart #112]] 
                    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:35) 
                    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185) 
                    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400) 
                    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96) 
                    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312) 
                    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276) 
                    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67) 
                    at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:136) 
                    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) 
                    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59) 
                    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
                    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
                    at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE
      

       

      In a declarative pipeline{} Jenkins then re-executes the job.  I added an uptime check statement to avoid the ensuing infinite loop. Also, setting the option 'disableResume()' in the UI or in the pipeline{} did nothing to stop the re-execution.

      When I moved the restart out of the pipeline{} block and into a lower node { stage {} }, the result of the job and output are identical, but Jenkins does not try to re-run the job from the beginning.

      I'm attaching an example Jenkinsfile with just enough to replicate the issue, as well as the supporting library used in the Global Shared Libraries for the restart call and uptime calculation.

      I've listed the relevant plugins installed with versions (at least as far as I can tell) in the environment section.

       

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            homebrew Ryan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: