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

Double escaping of quotes cause windows kubernetes-based agents to hang on 'bat'

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      1.28.7

      Description

      A recent change to the kubernetes plugin released as v1.28.6: https://github.com/jenkinsci/kubernetes-plugin/pull/924 to escape double quotes causes `bat` commands to 'hang' in windows based agents.

      Steps to reproduce

      Update kubernetes-plugin to v1.28.6. Or checkout  v1.28.5 (working) and merge: 3463a4ace479a4dc5badd0b642d6d9982c7b4822 , build & install on a Jenkins. Run a simple pipeline:

      podTemplate(cloud: "kubeprod", nodeSelector: "beta.kubernetes.io/os=windows", containers: [
          containerTemplate(name: "jnlp", image:"myrepo.company/jenkins-jnlp-slave:windows", alwaysPullImage:false, ttyEnabled:false, 
              resourceRequestCpu:'1', resourceLimitCpu:'2', resourceRequestMemory:'1Gi', resourceLimitMemory:'2Gi'),
          containerTemplate(name: "wind", image: 'myrepo.company/dotnet-framework/4.8-sdk-windowsservercore-ltsc2019', alwaysPullImage: false, ttyEnabled:true,  
              resourceRequestCpu:'1', resourceLimitCpu:'2', resourceRequestMemory:'1Gi', resourceLimitMemory:'2Gi', command:'cmd') 
        ]) {
            node(POD_LABEL) {
                stage("Test") {
                      container("wind")
          					{
                          bat(returnStdout:true, script: 'echo "Build is starting"');
          					}
                  }
            }
        }
      
      

      In the build log, hangs at the bat stage infinitely:

      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Test)
      [Pipeline] container
      [Pipeline] {
      [Pipeline] bat
      

      This only happens when switching to another container(...)


      On v1.28.5 (working) the value of fixedCommand (657) src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java is:

      cmd /c ""/home/jenkins/agent/workspace/windows-test@tmp/durable-5f508532/jenkins-wrap.bat"" 
      

      On v1.28.6 (or v1.28.5 with 3463a4 merged) not working the value of fixedCommand (657) src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java is:

      cmd /c \"\"/home/jenkins/agent/workspace/windows-test@tmp/durable-c7f52994/jenkins-wrap.bat\"\"
      

      From the difference of the two, we can see from the quotes are double escaped and this causes any 'bat' command to hang.

       

      Workarounds

      Downgrade to kubernetes plugin to v1.28.5

        Attachments

          Issue Links

            Activity

            Hide
            vlatombe Vincent Latombe added a comment -

            Thanks for the notice, I have reverted the problematic change until I get a proper fix for this use case.

            Show
            vlatombe Vincent Latombe added a comment - Thanks for the notice, I have reverted the problematic change until I get a proper fix for this use case.

              People

              Assignee:
              vlatombe Vincent Latombe
              Reporter:
              cyanoth Charles K
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: