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

using 'path' in a pipeline param breaks powershell with kubernetes

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • kubernetes-plugin
    • None
    • windows

      Given:

      • Jenkins 2.319.2
      • kubernetes-plugin 1.31.3
      • a Windows (ltsc2019) kubernetes cluster

      When:

      1. Setup a pipeline with two containers (jnlp + windowsservercore)
      2. Add a parameter of type text
      3. Have the pipeline execute a simple powershell command on the non-jnlp container (ex. pwd)
      4. Run the pipeline with the text parameter set to:

       

      .
      path x

      n.b. the '.' is not important to reproduce, but the newline after it is

      Expectations:

      • The pipeline should execute the command

      Observations:

      • The pipeline hangs infinitely on the powershell command

       

      Additional details:

      Here is a sample pipeline that reproduces the issue

       

      pipeline {
        agent { 
          kubernetes {
            yaml '''\
      ---
      apiVersion: "v1"
      kind: "Pod"
      spec:
        containers:
        - args:
          - "Start-Sleep"
          - "999999"
          command:
          - "powershell"
          image: "mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019"
          name: "windowsservercore"
          volumeMounts:
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
          workingDir: "/home/jenkins/agent"
        - image: "jenkins/inbound-agent:jdk11-windowsservercore-ltsc2019"
          name: "jnlp"
          resources:
            requests:
              memory: "1024Mi"
              cpu: "250m"
          volumeMounts:
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
          workingDir: "/home/jenkins/agent"
        nodeSelector:
          kubernetes.io/os: "windows"
        tolerations:
        - effect: "NoSchedule"
          key: "OS"
          operator: "Equal"
          value: "Windows"
        volumes:
        - emptyDir:
            medium: ""
          name: "workspace-volume"
      '''
          }
        }
        parameters {
          text(name: 'myparam', defaultValue: "\npath x", description: 'myparam')
        }
      
        stages {
          stage('Test') {
            steps {
              script {
                container('windowsservercore') {
                  powershell "pwd"
                }
              }
            }
          }
        }
      }
      

       

      Sample output:

      [Pipeline] Start of Pipeline
      [Pipeline] podTemplate
      [Pipeline] {
      [Pipeline] node
      Created Pod: kubernetes jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc
      [Normal][jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc][Scheduled] Successfully assigned jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc to canolsk8s01j
      [Normal][jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc][Pulled] Container image "mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019" already present on machine
      [Normal][jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc][Created] Created container windowsservercore
      [Normal][jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc][Started] Started container windowsservercore
      [Normal][jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc][Pulled] Container image "jenkins/inbound-agent:jdk11-windowsservercore-ltsc2019" already present on machine
      [Normal][jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc][Created] Created container jnlp
      [Normal][jenkins/osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc][Started] Started container jnlp
      Still waiting to schedule task
      ‘osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc’ is offline
      Agent osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc is provisioned from template osdk-gpetit_tests_test-long-params_43-n3gmp-qfqq1
      ---
      apiVersion: "v1"
      kind: "Pod"
      metadata:
        annotations:
          buildUrl: "http://jenkins.jenkins.svc.cluster.local:80/job/osdk-gpetit/job/tests/job/test-long-params/43/"
          runUrl: "job/osdk-gpetit/job/tests/job/test-long-params/43/"
        labels:
          jenkins: "slave"
          jenkins/label-digest: "009d92f111e8a72c2c59471c07aa207cb7b8b04d"
          jenkins/label: "osdk-gpetit_tests_test-long-params_43-n3gmp"
        name: "osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc"
      spec:
        containers:
        - args:
          - "Start-Sleep"
          - "999999"
          command:
          - "powershell"
          image: "mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019"
          name: "windowsservercore"
          volumeMounts:
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
          workingDir: "/home/jenkins/agent"
        - env:
          - name: "JENKINS_SECRET"
            value: "********"
          - name: "JENKINS_TUNNEL"
            value: "jenkins-agent.jenkins.svc.cluster.local:50000"
          - name: "JENKINS_AGENT_NAME"
            value: "osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc"
          - name: "JENKINS_NAME"
            value: "osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc"
          - name: "JENKINS_AGENT_WORKDIR"
            value: "/home/jenkins/agent"
          - name: "JENKINS_URL"
            value: "http://jenkins.jenkins.svc.cluster.local:80/"
          image: "jenkins/inbound-agent:jdk11-windowsservercore-ltsc2019"
          name: "jnlp"
          resources:
            requests:
              memory: "1024Mi"
              cpu: "250m"
          volumeMounts:
          - mountPath: "/home/jenkins/agent"
            name: "workspace-volume"
            readOnly: false
          workingDir: "/home/jenkins/agent"
        nodeSelector:
          kubernetes.io/os: "windows"
        restartPolicy: "Never"
        tolerations:
        - effect: "NoSchedule"
          key: "OS"
          operator: "Equal"
          value: "Windows"
        volumes:
        - emptyDir:
            medium: ""
          name: "workspace-volume"
      
      Running on osdk-gpetit-tests-test-long-params-43-n3gmp-qfqq1-274bc in /home/jenkins/agent/workspace/osdk-gpetit/tests/test-long-params
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Test)
      [Pipeline] script
      [Pipeline] {
      [Pipeline] container
      [Pipeline] {
      [Pipeline] powershell
      

      It seems like the path word in the param is interpreted on the windows containers and end up messing up the containers.

      I could not find any log helping, but I'll be happy to provide any other additional detail necessary.

       

          [JENKINS-67715] using 'path' in a pipeline param breaks powershell with kubernetes

          There are no comments yet on this issue.

            Unassigned Unassigned
            gpetit Gaspard Petit
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: