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

sh step on z/OS with encoding parameter set to UTF-8 hangs when trying to read jenkins-result.txt

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • durable-task-plugin
    • None
    • z/OS

      When running sh step on z/OS with encoding set to UTF-8 the step execution hangs when trying to read the jenkins-result.txt file. This is because the file is in native EBCDIC encoding, but it is read with UTF-8 encoding specified in sh step.

      Following pipeline is used for reproduction:

       

      pipeline {
          agent{node('zOS-node')}    
          stages {
              stage('example for bugreport')   {
                  steps {
                      sh(script:'''#!/bin/sh -e
                          echo "UTF-8 output" | iconv -f 1047 -t utf-8''', 
                          encoding:'UTF-8')
                  }
              }
          }
      } 

      Execution results in:

      [Pipeline] // stage
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (example for bugreport)
      [Pipeline] sh
      UTF-8 output
      Cannot contact zOS-node: java.io.IOException: corrupted content in /[path removed]/durable-040db3a4/jenkins-result.txt: java.lang.NumberFormatException: For input string: "�"
      

      In my understanding on z/OS the jenkins-result.txt is always in native encoding as it is generated via shell scripts generated at https://github.com/jenkinsci/durable-task-plugin/blob/aa22cf15d5e07bd99247e71ed467ae5107b74d73/src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java#L231 and following lines. Hence, it should be read with native encoding instead of encoding specified in sh step (which is intended for output/payload). I’ll come up with a PR.

          [JENKINS-72436] sh step on z/OS with encoding parameter set to UTF-8 hangs when trying to read jenkins-result.txt

          Lutz Neugebauer created issue -
          Lutz Neugebauer made changes -
          Description Original: When running sh step on z/OS with encoding set to UTF-8 the step execution hangs when trying to read the jenkins-result.txt file. This is because the file is in native EBCDIC encoding, but it is read with UTF-8 encoding specified in sh step.

          Following pipeline is used for reproduction:

           
          {code:java}
          pipeline {
              agent{node('zOS-node')}    stages {
                  stage('example for bugreport')   {
                      steps {
                          sh(script:'''#!/bin/sh -e
                              echo "UTF-8 output" | iconv -f 1047 -t utf-8''', 
                              encoding:'UTF-8')
                      }
                  }
              }
          } {code}
          Execution results in:
          {code:java}
          [Pipeline] // stage
          [Pipeline] withEnv
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (example for bugreport)
          [Pipeline] sh
          UTF-8 output
          Cannot contact zOS-node: java.io.IOException: corrupted content in /[path removed]/durable-040db3a4/jenkins-result.txt: java.lang.NumberFormatException: For input string: "�"
          {code}
          In my understanding on z/OS the jenkins-result.txt is always in native encoding as it is generated via shell scripts generated at [https://github.com/jenkinsci/durable-task-plugin/blob/aa22cf15d5e07bd99247e71ed467ae5107b74d73/src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java#L231] and following lines. Hence, it should be read with native encoding instead of encoding specified in sh step (which is intended for output/payload). I’ll come up with a PR.
          New: When running sh step on z/OS with encoding set to UTF-8 the step execution hangs when trying to read the jenkins-result.txt file. This is because the file is in native EBCDIC encoding, but it is read with UTF-8 encoding specified in sh step.

          Following pipeline is used for reproduction:

           
          {code:java}
          pipeline {
              agent{node('zOS-node')}   
              stages {
                  stage('example for bugreport')   {
                      steps {
                          sh(script:'''#!/bin/sh -e
                              echo "UTF-8 output" | iconv -f 1047 -t utf-8''', 
                              encoding:'UTF-8')
                      }
                  }
              }
          } {code}
          Execution results in:
          {code:java}
          [Pipeline] // stage
          [Pipeline] withEnv
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (example for bugreport)
          [Pipeline] sh
          UTF-8 output
          Cannot contact zOS-node: java.io.IOException: corrupted content in /[path removed]/durable-040db3a4/jenkins-result.txt: java.lang.NumberFormatException: For input string: "�"
          {code}
          In my understanding on z/OS the jenkins-result.txt is always in native encoding as it is generated via shell scripts generated at [https://github.com/jenkinsci/durable-task-plugin/blob/aa22cf15d5e07bd99247e71ed467ae5107b74d73/src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java#L231] and following lines. Hence, it should be read with native encoding instead of encoding specified in sh step (which is intended for output/payload). I’ll come up with a PR.

          I raised PR#199.

          Lutz Neugebauer added a comment - I raised PR#199 .
          Lutz Neugebauer made changes -
          Link New: This issue is related to JENKINS-70660 [ JENKINS-70660 ]
          Lutz Neugebauer made changes -
          Released As New: https://github.com/jenkinsci/durable-task-plugin/releases/tag/543.v262f6a_803410
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            Unassigned Unassigned
            lne Lutz Neugebauer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: