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

          mocsharp created issue -
          mocsharp made changes -
          Priority Original: Major [ 3 ] New: Minor [ 4 ]

          mocsharp added a comment - - edited

          I tested it again with local Windows 2012 R2 and it worked fine. However, when it's configured on ec2 using WinRM, the process would never exit.

          If slave is conneted using JNLP, the process exits fine.

          mocsharp added a comment - - edited I tested it again with local Windows 2012 R2 and it worked fine. However, when it's configured on ec2 using WinRM, the process would never exit. If slave is conneted using JNLP, the process exits fine.
          mocsharp made changes -
          Component/s New: ec2-plugin [ 15625 ]

          Carlos Lucas added a comment - - edited

          I am having this problem on a Windows 2012 too, but I have it in the main node of jenkins.

          Downgrading the Durable Task Plugin to 1.7 solves de problem.

          Carlos Lucas added a comment - - edited I am having this problem on a Windows 2012 too, but I have it in the main node of jenkins. Downgrading the Durable Task Plugin to 1.7 solves de problem.
          Carlos Lucas made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]
          Carlos Lucas made changes -
          Priority Original: Major [ 3 ] New: Minor [ 4 ]

          Samuel Garcia added a comment -

          I'm having the same problem on a Windows 7 Professional SP1. Jenkins 1.652, Durable Task Plugin 1.8.

          My pipeline script that uses the 'bat' command hangs after the command has been successfully executed. I can't even kill the job, not even with the 'forcibly terminate' link that appears on the job's console. I have to stop Jenkins from the 'Services' window of Windows, then remove the job's folder.

          Is there any workaround for this? Since Jenkins won't allow me to downgrade the Durable Task Plugin

          Samuel Garcia added a comment - I'm having the same problem on a Windows 7 Professional SP1. Jenkins 1.652, Durable Task Plugin 1.8. My pipeline script that uses the 'bat' command hangs after the command has been successfully executed. I can't even kill the job, not even with the 'forcibly terminate' link that appears on the job's console. I have to stop Jenkins from the 'Services' window of Windows, then remove the job's folder. Is there any workaround for this? Since Jenkins won't allow me to downgrade the Durable Task Plugin

          Andreas Schroeder added a comment - - edited

          I have the same problem now on a Windows Server 2008 R2 Standard 64 Bit machine with Jenkins 1.654 and Pipeline plugin 1.15.

          I investigated a bit by using this Groovy script:
          node
          {
          for(int i=0; i < 100; ++i)

          { bat('echo "Hello from batch file."' + i.toString()) }

          }
          Jenkins creates two temporary batch files to run each "bat" call: jenkins-main.bat with the "echo ..." command and jenkins-wrap.bat to redirect output and capture the exit code in two text files jenkins-log.txt and jenkins-result.txt.

          At first the Groovy script is executing the bat call a few times correctly and then stops waiting. The console output does nothing but spin this little icon. When this happens, you can find the following state:

          • a "durable-XXXXXXXX" folder (x are hex numbers) in a temporary workspace containing the two batch files jenkins-main.bat and jenkins-wrap.bat.
          • The task manager does not show any of the batch files executing.
          • The two text files jenkins-log.txt and jenkins-result.txt are not there

          Now I have found two ways to make Jenkins continue execting the Groovy script:

          • run the jenkins-wrap.bat manually
          • create the jenkins-log.txt file (can be empty) and the jenkins-result.txt file with a integer number as content, e.g. 0.

          I guess there are two ways this could happen (currently I do not know how to verify this): Either the jenkins-wrap.bat terminates without creating the text files. Or there is some race condition in the Jenkins code deleting the text files before they can be read.

          Andreas Schroeder added a comment - - edited I have the same problem now on a Windows Server 2008 R2 Standard 64 Bit machine with Jenkins 1.654 and Pipeline plugin 1.15. I investigated a bit by using this Groovy script: node { for(int i=0; i < 100; ++i) { bat('echo "Hello from batch file."' + i.toString()) } } Jenkins creates two temporary batch files to run each "bat" call: jenkins-main.bat with the "echo ..." command and jenkins-wrap.bat to redirect output and capture the exit code in two text files jenkins-log.txt and jenkins-result.txt. At first the Groovy script is executing the bat call a few times correctly and then stops waiting. The console output does nothing but spin this little icon. When this happens, you can find the following state: a "durable-XXXXXXXX" folder (x are hex numbers) in a temporary workspace containing the two batch files jenkins-main.bat and jenkins-wrap.bat. The task manager does not show any of the batch files executing. The two text files jenkins-log.txt and jenkins-result.txt are not there Now I have found two ways to make Jenkins continue execting the Groovy script: run the jenkins-wrap.bat manually create the jenkins-log.txt file (can be empty) and the jenkins-result.txt file with a integer number as content, e.g. 0. I guess there are two ways this could happen (currently I do not know how to verify this): Either the jenkins-wrap.bat terminates without creating the text files. Or there is some race condition in the Jenkins code deleting the text files before they can be read.
          Jesse Glick made changes -
          Component/s New: durable-task-plugin [ 18622 ]
          Component/s Original: ec2-plugin [ 15625 ]
          Component/s Original: workflow-plugin [ 18820 ]

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

              Created:
              Updated: