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

Wrong EOL (UNIX type: LF) in Windows batch files executed for build steps of type "Execute Windows batch command"

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • Windows 2008 Server R2, Enterprise Edition, x64

      For a build step of type "Execute Windows batch command" Hudson generates and then executes a .bat file using the content provided by the user in the configuration textbox of the step.

      The problem is that the generated .bat file has UNIX style EOL (lines ending with LF) and the Windows Command Interpreter (CMD.EXE) requires Windows style EOLs (lines ending with CR LF) in batches, in order to interpret them correctly.

      The consequences of having UNIX style EOL in Windows batches is undetermined. Very simple batches work while more complex ones will behave erratically because CMD.EXE will consume multiple lines in one command and it will fail to find some labels.

          [JENKINS-7478] Wrong EOL (UNIX type: LF) in Windows batch files executed for build steps of type "Execute Windows batch command"

          Daniel Beck added a comment -

          Does this issue still occur for anyone in recent Jenkins versions? I have never experienced this on Jenkins 1.415 and newer...

          Daniel Beck added a comment - Does this issue still occur for anyone in recent Jenkins versions? I have never experienced this on Jenkins 1.415 and newer...

          Still have this issue on 1.556.
          The exact script is http://rand.org.ru/upload/hudson2498629865472256615.bat. The slave system information is http://pastebin.com/xL47Vz3g. The master is running under Linux.

          Andrey Rogozhnikov added a comment - Still have this issue on 1.556. The exact script is http://rand.org.ru/upload/hudson2498629865472256615.bat . The slave system information is http://pastebin.com/xL47Vz3g . The master is running under Linux.

          David Ruhmann added a comment - - edited

          Still have this issue on 1.563
          Using Firefox 29 and Chrome 34 the

          

          character does not get written out. Only when using IE (11 in my case) does it write out correctly.

          So it would seem that Jenkins is not compatible with Firefox or Chrome.

          David Ruhmann added a comment - - edited Still have this issue on 1.563 Using Firefox 29 and Chrome 34 the 
 character does not get written out. Only when using IE (11 in my case) does it write out correctly. So it would seem that Jenkins is not compatible with Firefox or Chrome.

          Oleg Nenashev added a comment -

          Oleg Nenashev added a comment - David's PR: https://github.com/jenkinsci/jenkins/pull/1361

          David Ruhmann added a comment -

          David Ruhmann added a comment - New PR: https://github.com/jenkinsci/jenkins/pull/1370

          Code changed in jenkins
          User: David Ruhmann
          Path:
          core/src/main/java/hudson/tasks/BatchFile.java
          core/src/main/java/hudson/tasks/Shell.java
          core/src/main/java/hudson/tools/AbstractCommandInstaller.java
          core/src/main/java/hudson/tools/BatchCommandInstaller.java
          core/src/main/java/hudson/tools/CommandInstaller.java
          core/src/main/java/hudson/util/LineEndingConversion.java
          test/src/test/java/hudson/tasks/BatchFileTest.java
          test/src/test/java/hudson/tasks/ShellTest.java
          test/src/test/java/hudson/tools/BatchCommandInstallerTest.java
          test/src/test/java/hudson/tools/CommandInstallerTest.java
          test/src/test/java/hudson/util/LineEndingConversionTest.java
          http://jenkins-ci.org/commit/jenkins/67ac47af0709dde6297dffeb210b03d8b65f6033
          Log:
          [FIXED JENKINS-7478]

          Create Line Ending Conversion utility to convert scripts to proper OS
          line ending type. Tests included.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: David Ruhmann Path: core/src/main/java/hudson/tasks/BatchFile.java core/src/main/java/hudson/tasks/Shell.java core/src/main/java/hudson/tools/AbstractCommandInstaller.java core/src/main/java/hudson/tools/BatchCommandInstaller.java core/src/main/java/hudson/tools/CommandInstaller.java core/src/main/java/hudson/util/LineEndingConversion.java test/src/test/java/hudson/tasks/BatchFileTest.java test/src/test/java/hudson/tasks/ShellTest.java test/src/test/java/hudson/tools/BatchCommandInstallerTest.java test/src/test/java/hudson/tools/CommandInstallerTest.java test/src/test/java/hudson/util/LineEndingConversionTest.java http://jenkins-ci.org/commit/jenkins/67ac47af0709dde6297dffeb210b03d8b65f6033 Log: [FIXED JENKINS-7478] Create Line Ending Conversion utility to convert scripts to proper OS line ending type. Tests included.

          Code changed in jenkins
          User: Daniel Beck
          Path:
          core/src/main/java/hudson/tasks/BatchFile.java
          core/src/main/java/hudson/tasks/Shell.java
          core/src/main/java/hudson/tools/AbstractCommandInstaller.java
          core/src/main/java/hudson/tools/BatchCommandInstaller.java
          core/src/main/java/hudson/tools/CommandInstaller.java
          core/src/main/java/hudson/util/LineEndingConversion.java
          test/src/test/java/hudson/tasks/BatchFileTest.java
          test/src/test/java/hudson/tasks/ShellTest.java
          test/src/test/java/hudson/tools/BatchCommandInstallerTest.java
          test/src/test/java/hudson/tools/CommandInstallerTest.java
          test/src/test/java/hudson/util/LineEndingConversionTest.java
          http://jenkins-ci.org/commit/jenkins/3d25f57aa1352359331675c05cd387e6bc536a3a
          Log:
          Merge pull request #1370 from DavidRuhmann/JENKINS-7478

          [FIXED JENKINS-7478] Correct Line Endings for Batch Files

          Compare: https://github.com/jenkinsci/jenkins/compare/8bb88be27ec4...3d25f57aa135

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: core/src/main/java/hudson/tasks/BatchFile.java core/src/main/java/hudson/tasks/Shell.java core/src/main/java/hudson/tools/AbstractCommandInstaller.java core/src/main/java/hudson/tools/BatchCommandInstaller.java core/src/main/java/hudson/tools/CommandInstaller.java core/src/main/java/hudson/util/LineEndingConversion.java test/src/test/java/hudson/tasks/BatchFileTest.java test/src/test/java/hudson/tasks/ShellTest.java test/src/test/java/hudson/tools/BatchCommandInstallerTest.java test/src/test/java/hudson/tools/CommandInstallerTest.java test/src/test/java/hudson/util/LineEndingConversionTest.java http://jenkins-ci.org/commit/jenkins/3d25f57aa1352359331675c05cd387e6bc536a3a Log: Merge pull request #1370 from DavidRuhmann/ JENKINS-7478 [FIXED JENKINS-7478] Correct Line Endings for Batch Files Compare: https://github.com/jenkinsci/jenkins/compare/8bb88be27ec4...3d25f57aa135

          dogfood added a comment -

          Integrated in jenkins_main_trunk #3687
          [FIXED JENKINS-7478] (Revision 67ac47af0709dde6297dffeb210b03d8b65f6033)

          Result = SUCCESS
          david.ruhmann : 67ac47af0709dde6297dffeb210b03d8b65f6033
          Files :

          • test/src/test/java/hudson/util/LineEndingConversionTest.java
          • test/src/test/java/hudson/tools/BatchCommandInstallerTest.java
          • core/src/main/java/hudson/tools/BatchCommandInstaller.java
          • test/src/test/java/hudson/tools/CommandInstallerTest.java
          • core/src/main/java/hudson/tasks/Shell.java
          • test/src/test/java/hudson/tasks/ShellTest.java
          • core/src/main/java/hudson/util/LineEndingConversion.java
          • core/src/main/java/hudson/tasks/BatchFile.java
          • core/src/main/java/hudson/tools/CommandInstaller.java
          • core/src/main/java/hudson/tools/AbstractCommandInstaller.java
          • test/src/test/java/hudson/tasks/BatchFileTest.java

          dogfood added a comment - Integrated in jenkins_main_trunk #3687 [FIXED JENKINS-7478] (Revision 67ac47af0709dde6297dffeb210b03d8b65f6033) Result = SUCCESS david.ruhmann : 67ac47af0709dde6297dffeb210b03d8b65f6033 Files : test/src/test/java/hudson/util/LineEndingConversionTest.java test/src/test/java/hudson/tools/BatchCommandInstallerTest.java core/src/main/java/hudson/tools/BatchCommandInstaller.java test/src/test/java/hudson/tools/CommandInstallerTest.java core/src/main/java/hudson/tasks/Shell.java test/src/test/java/hudson/tasks/ShellTest.java core/src/main/java/hudson/util/LineEndingConversion.java core/src/main/java/hudson/tasks/BatchFile.java core/src/main/java/hudson/tools/CommandInstaller.java core/src/main/java/hudson/tools/AbstractCommandInstaller.java test/src/test/java/hudson/tasks/BatchFileTest.java

          Code changed in jenkins
          User: David Ruhmann
          Path:
          core/src/main/java/hudson/tasks/BatchFile.java
          core/src/main/java/hudson/tasks/Shell.java
          core/src/main/java/hudson/tools/AbstractCommandInstaller.java
          core/src/main/java/hudson/tools/BatchCommandInstaller.java
          core/src/main/java/hudson/tools/CommandInstaller.java
          core/src/main/java/hudson/util/LineEndingConversion.java
          test/src/test/java/hudson/tasks/BatchFileTest.java
          test/src/test/java/hudson/tasks/ShellTest.java
          test/src/test/java/hudson/tools/BatchCommandInstallerTest.java
          test/src/test/java/hudson/tools/CommandInstallerTest.java
          test/src/test/java/hudson/util/LineEndingConversionTest.java
          http://jenkins-ci.org/commit/jenkins/efae48a451b1dbb15a13abff26b0bec269a63909
          Log:
          [FIXED JENKINS-7478]

          Create Line Ending Conversion utility to convert scripts to proper OS
          line ending type. Tests included.

          (cherry picked from commit 67ac47af0709dde6297dffeb210b03d8b65f6033)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: David Ruhmann Path: core/src/main/java/hudson/tasks/BatchFile.java core/src/main/java/hudson/tasks/Shell.java core/src/main/java/hudson/tools/AbstractCommandInstaller.java core/src/main/java/hudson/tools/BatchCommandInstaller.java core/src/main/java/hudson/tools/CommandInstaller.java core/src/main/java/hudson/util/LineEndingConversion.java test/src/test/java/hudson/tasks/BatchFileTest.java test/src/test/java/hudson/tasks/ShellTest.java test/src/test/java/hudson/tools/BatchCommandInstallerTest.java test/src/test/java/hudson/tools/CommandInstallerTest.java test/src/test/java/hudson/util/LineEndingConversionTest.java http://jenkins-ci.org/commit/jenkins/efae48a451b1dbb15a13abff26b0bec269a63909 Log: [FIXED JENKINS-7478] Create Line Ending Conversion utility to convert scripts to proper OS line ending type. Tests included. (cherry picked from commit 67ac47af0709dde6297dffeb210b03d8b65f6033)

          dogfood added a comment -

          Integrated in jenkins_main_trunk #4292
          [FIXED JENKINS-7478] (Revision efae48a451b1dbb15a13abff26b0bec269a63909)

          Result = UNSTABLE
          ogondza : efae48a451b1dbb15a13abff26b0bec269a63909
          Files :

          • test/src/test/java/hudson/tools/CommandInstallerTest.java
          • core/src/main/java/hudson/tasks/BatchFile.java
          • core/src/main/java/hudson/tasks/Shell.java
          • test/src/test/java/hudson/tasks/BatchFileTest.java
          • core/src/main/java/hudson/tools/CommandInstaller.java
          • test/src/test/java/hudson/tools/BatchCommandInstallerTest.java
          • core/src/main/java/hudson/tools/BatchCommandInstaller.java
          • test/src/test/java/hudson/util/LineEndingConversionTest.java
          • test/src/test/java/hudson/tasks/ShellTest.java
          • core/src/main/java/hudson/util/LineEndingConversion.java
          • core/src/main/java/hudson/tools/AbstractCommandInstaller.java

          dogfood added a comment - Integrated in jenkins_main_trunk #4292 [FIXED JENKINS-7478] (Revision efae48a451b1dbb15a13abff26b0bec269a63909) Result = UNSTABLE ogondza : efae48a451b1dbb15a13abff26b0bec269a63909 Files : test/src/test/java/hudson/tools/CommandInstallerTest.java core/src/main/java/hudson/tasks/BatchFile.java core/src/main/java/hudson/tasks/Shell.java test/src/test/java/hudson/tasks/BatchFileTest.java core/src/main/java/hudson/tools/CommandInstaller.java test/src/test/java/hudson/tools/BatchCommandInstallerTest.java core/src/main/java/hudson/tools/BatchCommandInstaller.java test/src/test/java/hudson/util/LineEndingConversionTest.java test/src/test/java/hudson/tasks/ShellTest.java core/src/main/java/hudson/util/LineEndingConversion.java core/src/main/java/hudson/tools/AbstractCommandInstaller.java

            davidruhmann David Ruhmann
            bogdaniosif bogdaniosif
            Votes:
            6 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: