I have Jenkins slave nodes configured on Windows Server 2012 with a very simple pipeline script:

      node('js-win') {
      	stage 'Checkout'
      	checkout scm
      	stage 'Build'
      	bat 'dir'
      }
      

      At the end of the script, from the Console output, it would just spin and hang after listing all the files.

          [JENKINS-33164] Pipeline bat stuck on Windows Server 2012

          Christophe Carpentier added a comment - - edited

          Yup, definitely a blocker.

          Christophe Carpentier added a comment - - edited Yup, definitely a blocker.

          Geoff Rowell added a comment -

          I believe that this issue is caused by having the same agent/node executing the pipeline script as is targeted by the script.

          My initial setup had a Win7x64 master node that ran a pipeline script that included "node" commands that targeted the master node - as well as a secondary Win2008r2 node. This was able to reproduce the hang.

          Once I moved the master node to a CentOS 7 VM, and adjusted the script accordingly, I was able to reliably run the job. With this setup, all of the "heavyweight" executors are delegated to the remote agents.

          BTW, I'm using Jenkins 2.0.

          Geoff Rowell added a comment - I believe that this issue is caused by having the same agent/node executing the pipeline script as is targeted by the script. My initial setup had a Win7x64 master node that ran a pipeline script that included "node" commands that targeted the master node - as well as a secondary Win2008r2 node. This was able to reproduce the hang. Once I moved the master node to a CentOS 7 VM, and adjusted the script accordingly, I was able to reliably run the job. With this setup, all of the "heavyweight" executors are delegated to the remote agents. BTW, I'm using Jenkins 2.0.

          Nick Sonneveld added a comment - - edited

          Sorry that might be a red herring. I have been testing exclusively with a Linux master and a combination of linux and windows nodes. I still see this behaviour.

          edit1: However, I usually see it after running many batch scripts (around 400) on 30 executors across 4 nodes.
          edit2: It might also involve terminating jobs in the middle of running scripts

          Nick Sonneveld added a comment - - edited Sorry that might be a red herring. I have been testing exclusively with a Linux master and a combination of linux and windows nodes. I still see this behaviour. edit1: However, I usually see it after running many batch scripts (around 400) on 30 executors across 4 nodes. edit2: It might also involve terminating jobs in the middle of running scripts

          Andrew Coats added a comment - - edited

          I am having the same issue. Using Windows 10 Pro (Version 1511). Jenkins 2.1 with all the plugins at the latest version (5/5/2016).

          My workaround is to continue using Freestyle projects - but I was hoping to use the pipeline projects in order get a history of changes in GIT.

          Results (nunit2) saved as CalAgPermits.Maps.Web.UnitTests.xml
          Aborted by Andrew Coats
          Sending interrupt signal to process
          Click here to forcibly terminate running steps

          The "click here to forcibly terminate running steps" does not seem to work. Once the pipeline job is stuck - I have to reboot the machine and delete the pipeline job. If I do not delete the pipeline job... the job gets stuck in the build queue again even after the reboot (proving that pipeline jobs are durable!).

          Andrew Coats added a comment - - edited I am having the same issue. Using Windows 10 Pro (Version 1511). Jenkins 2.1 with all the plugins at the latest version (5/5/2016). My workaround is to continue using Freestyle projects - but I was hoping to use the pipeline projects in order get a history of changes in GIT. Results (nunit2) saved as CalAgPermits.Maps.Web.UnitTests.xml Aborted by Andrew Coats Sending interrupt signal to process Click here to forcibly terminate running steps The "click here to forcibly terminate running steps" does not seem to work. Once the pipeline job is stuck - I have to reboot the machine and delete the pipeline job. If I do not delete the pipeline job... the job gets stuck in the build queue again even after the reboot (proving that pipeline jobs are durable!).

          Julien Faixo added a comment -

          Same issue here.

          OS: Windows Server 2012 R2
          Jenkins: 2.5, all plugins up to date (20/05/2016)

          Unable to run any bat command (the first one hangs and never returns). Same workarounds as said :

          • in order to stop the task : click on the red cross on the build in order to send a killing signal, then go to the console output and click the "Terminate" link
          • in order to be able to build something : stick with the Freestyle projects for now

          It makes Pipeline unusable on Windows.

          Julien Faixo added a comment - Same issue here. OS: Windows Server 2012 R2 Jenkins: 2.5, all plugins up to date (20/05/2016) Unable to run any bat command (the first one hangs and never returns). Same workarounds as said : in order to stop the task : click on the red cross on the build in order to send a killing signal, then go to the console output and click the "Terminate" link in order to be able to build something : stick with the Freestyle projects for now It makes Pipeline unusable on Windows.

          Jesse Glick added a comment -

          all plugins up to date (20/05/2016)

          I need more details than that. durable-task 1.10, with an important fix for Windows users, was released around that time. And it is driven by workflow-durable-task-step.

          Jesse Glick added a comment - all plugins up to date (20/05/2016) I need more details than that. durable-task 1.10, with an important fix for Windows users, was released around that time. And it is driven by workflow-durable-task-step .

          Jesse Glick added a comment -

          Tried again to reproduce on 2012 without success. Also checked stopping and restarting Jenkins as java -jar jenkins.war while

          node {
              bat 'ping -n 100 localhost'
          }
          

          was running, which worked fine. I did see that if you install Jenkins as a Windows service and use /safeRestart (not currently a GUI option), and the build is using a master executor, the restart itself kills the ping process (according to Task Manager), so upon resuming, the build will either hang (until you abort it and then “forcibly kill running steps”) or print

          Reply from ::1: time<1ms 
          Reply from ::1: time<1ms 
          Resuming build
          [Pipeline] }
          [Pipeline] // node
          [Pipeline] End of Pipeline
          ERROR: script returned exit code -1
          Finished: FAILURE
          

          since pending JENKINS-25053 Jenkins does not have a way of knowing that the process exited abnormally. This also seems to happen when using a JNLP slave installed as a service, which is more relevant (since running builds on the master is discouraged anyway). JENKINS-27617 would probably help.

          At any rate, issues with the actual process being inappropriately killed during restarts are not related to the far more fundamental problem reported here, which I am unable to reproduce.

          Jesse Glick added a comment - Tried again to reproduce on 2012 without success. Also checked stopping and restarting Jenkins as java -jar jenkins.war while node { bat 'ping -n 100 localhost' } was running, which worked fine. I did see that if you install Jenkins as a Windows service and use /safeRestart (not currently a GUI option), and the build is using a master executor, the restart itself kills the ping process (according to Task Manager), so upon resuming, the build will either hang (until you abort it and then “forcibly kill running steps”) or print Reply from ::1: time<1ms Reply from ::1: time<1ms Resuming build [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code -1 Finished: FAILURE since pending JENKINS-25053 Jenkins does not have a way of knowing that the process exited abnormally. This also seems to happen when using a JNLP slave installed as a service, which is more relevant (since running builds on the master is discouraged anyway). JENKINS-27617 would probably help. At any rate, issues with the actual process being inappropriately killed during restarts are not related to the far more fundamental problem reported here, which I am unable to reproduce.

          I have had this happen when my job name contained å,ä or ö.

          Erik Jonsson Thorén added a comment - I have had this happen when my job name contained å,ä or ö.

          Is somebody looking at this issue? I am also experiencing the same problem on Windows 10 and Windows 7 whenever i run a program with Batch.

          Enrique Ramirez added a comment - Is somebody looking at this issue? I am also experiencing the same problem on Windows 10 and Windows 7 whenever i run a program with Batch.

          We also hit this constantly on Win10. In our case it seems like if pipeline is trying to delete a running process then it will just be stuck there indefinitely. I can understand the headache of deleting files in use in general on windows, but I would hope that the Pipeline side of things could give up in accordance with the timeout settings we provide. Instead it will hang forever until we do the 3 step abort of terminating in the console.

          Justin Rainwater added a comment - We also hit this constantly on Win10. In our case it seems like if pipeline is trying to delete a running process then it will just be stuck there indefinitely. I can understand the headache of deleting files in use in general on windows, but I would hope that the Pipeline side of things could give up in accordance with the timeout settings we provide. Instead it will hang forever until we do the 3 step abort of terminating in the console.

            jglick Jesse Glick
            mocsharp mocsharp
            Votes:
            24 Vote for this issue
            Watchers:
            35 Start watching this issue

              Created:
              Updated: