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

XMLWordPrintable

    • 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.

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

              Created:
              Updated:
              Resolved: