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

Gradle plugin fails to quote parameters without whitespace when containing input/output redirection symbols, e.g. in XML strings

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • gradle-plugin
    • None
    • Windows Server 2008 R2
      Jenkins 1.424.6
      Jenkins Gradle Plugin 1.12

      Gradle plugin explicitly passes job parameters to the "cmd.exe /c gradle.bat" call.

      If one of these arguments looks like XML, but does not contain whitespace, it is not quoted. This leads to problems with input/output redirection symbols (less-than, greater-than)

      Example String Parameter value:

      <fail>
      

      Results in the following build output:

      [workspace] $ cmd.exe /C C:\path\to\gradle.bat -Dfoo=<fail> -i && exit %%ERRORLEVEL%%
      The system cannot find the file specified.
      Build step 'Invoke Gradle script' changed build result to FAILURE
      Build step 'Invoke Gradle script' marked build as failure
      Notifying upstream projects of job completion
      

      Real world example:
      Copy artifacts plugin's "Latest successful build" has the value:

      <StatusBuildSelector/>
      

      This results in "File not found" errors on Windows Server. Not tested on Linux.

          [JENKINS-13412] Gradle plugin fails to quote parameters without whitespace when containing input/output redirection symbols, e.g. in XML strings

          Daniel Beck created issue -

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/hudson/plugins/gradle/Gradle.java
          http://jenkins-ci.org/commit/gradle-plugin/ff6465b3681cf2dab7f5eb8dcb0eb7a3193df547
          Log:
          Fix JENKINS-13412

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/hudson/plugins/gradle/Gradle.java http://jenkins-ci.org/commit/gradle-plugin/ff6465b3681cf2dab7f5eb8dcb0eb7a3193df547 Log: Fix JENKINS-13412
          Gregory Boissinot made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Daniel Beck added a comment -

          It's not just real XML that's a problem here. Values such as `foo>bar` will also get interpreted as output redirection. Example:

          cmd.exe /c script.bat -Dfoo>bar
          

          This will redirect script.bat -Dfoo output to a file named bar.

          The calls in the examples fail, because there's no file named fail or StatusBuildSelector/, but the output issue is still unfixed. While this requires someone to explicitly enter parameter values such as this (instead of plugin use), and I don't have a good example, it should still be fixed.

          Daniel Beck added a comment - It's not just real XML that's a problem here. Values such as `foo>bar` will also get interpreted as output redirection. Example: cmd.exe /c script.bat -Dfoo>bar This will redirect script.bat -Dfoo output to a file named bar . The calls in the examples fail, because there's no file named fail or StatusBuildSelector/ , but the output issue is still unfixed. While this requires someone to explicitly enter parameter values such as this (instead of plugin use), and I don't have a good example, it should still be fixed.
          Daniel Beck made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/hudson/plugins/gradle/Gradle.java
          http://jenkins-ci.org/commit/gradle-plugin/8571382e23a33604148e7012ddcb95a43482c256
          Log:
          Fix JENKINS-13412

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/hudson/plugins/gradle/Gradle.java http://jenkins-ci.org/commit/gradle-plugin/8571382e23a33604148e7012ddcb95a43482c256 Log: Fix JENKINS-13412
          Gregory Boissinot made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Reopened [ 4 ] New: Resolved [ 5 ]

          Daniel Beck added a comment -

          1.16 fails for arguments that contain both spaces and angle brackets.

          [Gradle] - Launching build.
          [workspace] $ cmd.exe /C D:\jenkins\tools\Gradle-1.0-RC-1\bin\gradle.bat -Dtwo="<foo/>" "-Done=foo bar" '-Dthree="<foo> <bar> </foo>"' -i && exit %%ERRORLEVEL%%
          < was unexpected at this time.
          Build step 'Invoke Gradle script' changed build result to FAILURE
          

          Daniel Beck added a comment - 1.16 fails for arguments that contain both spaces and angle brackets. [Gradle] - Launching build. [workspace] $ cmd.exe /C D:\jenkins\tools\Gradle-1.0-RC-1\bin\gradle.bat -Dtwo= "<foo/>" "-Done=foo bar" '-Dthree= "<foo> <bar> </foo>" ' -i && exit %%ERRORLEVEL%% < was unexpected at this time. Build step 'Invoke Gradle script' changed build result to FAILURE
          Daniel Beck made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]

          I don't reproduce it.
          Maybe I don't understand very well.
          Could you attach your job configuration file (to have all information configuration)?

          Gregory Boissinot added a comment - I don't reproduce it. Maybe I don't understand very well. Could you attach your job configuration file (to have all information configuration)?

            gbois Gregory Boissinot
            danielbeck Daniel Beck
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: