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

Path separators in nested variables are not being escaped correctly when parsing the property file

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • envinject-plugin
    • Windows 7
    • EnvInject 2.2.1

      After the problem with 2.27 and windows slaves I tried 2.28 but ran into another new problem.
      Executing a windows batch file, the path separators are not converted to backslashes:
      Log from 2.26:
      set FOO=T:\Jenkins\workspace\...
      2.28:
      set FOO=T:/Jenkins/workspace/

      This does work for setting env vars but not when I try to call a windows executable/shell function:
      if exist T:/Jenkins/workspace/myproject/foo rmdir /s /q T:/Jenkins/workspace/myproject/foo
      --> Invalid switch - "Jenkins". because '/' is interpreted as a command line option

          [JENKINS-39403] Path separators in nested variables are not being escaped correctly when parsing the property file

          Christian Ehrlicher created issue -
          Christian Ehrlicher made changes -
          Component/s New: envinject-plugin [ 15893 ]
          Component/s Original: windows-slaves-plugin [ 18327 ]

          I really don't know what went wrong but now all works as expected - first thought there is a problem in the env inject plugin since it worked after downgrading from 1.93.1 to 1.93 but now also 1.93.1 works ...
          I'm closing this for now, sorry for the noise.

          Christian Ehrlicher added a comment - I really don't know what went wrong but now all works as expected - first thought there is a problem in the env inject plugin since it worked after downgrading from 1.93.1 to 1.93 but now also 1.93.1 works ... I'm closing this for now, sorry for the noise.
          Christian Ehrlicher made changes -
          Resolution New: Cannot Reproduce [ 5 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]

          Grigoriy Milman added a comment - - edited

          I just have seen the same issue during upgrading Jenkins from version 1.644 to 2.40
          Environment Injector Plugin was upgraded from 1.92.1 to 1.93.1

          The problem is the following: When environment variable contains directory or file path with Windows slash as path separator, the injected value of the variable will be string without slashes.
          Here is an example
          Properties Content are set as following in the job config: see PropertiesContent.PNG
          Corresponding fragment of the Console Output (see ConsoleOutput.PNG) with result of injection.
          The interesting thing is that "\target" became " arget" ( marked by yellow background).

          It should be mentioned here that usage forward slashes is not supported in Windows batch commands and windows command prompt, so replacements back slashes to forward slashes not an option in Windows environment.
          There is a related issue JENKINS-39131, which was set as "resolved". Unfortunately, such behavior makes Jenkins unusable in Windows environment: it is impossible to inject path related environment variables to any batch command or script where directory or file path is used!

          The problem disappeared after downgrading back Environment Injector Plugin from 1.93.1 to 1.92.1

          Grigoriy Milman added a comment - - edited I just have seen the same issue during upgrading Jenkins from version 1.644 to 2.40 Environment Injector Plugin was upgraded from 1.92.1 to 1.93.1 The problem is the following: When environment variable contains directory or file path with Windows slash as path separator, the injected value of the variable will be string without slashes. Here is an example Properties Content are set as following in the job config: see PropertiesContent.PNG Corresponding fragment of the Console Output (see ConsoleOutput.PNG ) with result of injection. The interesting thing is that "\target" became " arget" ( marked by yellow background). It should be mentioned here that usage forward slashes is not supported in Windows batch commands and windows command prompt, so replacements back slashes to forward slashes not an option in Windows environment. There is a related issue JENKINS-39131 , which was set as "resolved". Unfortunately, such behavior makes Jenkins unusable in Windows environment: it is impossible to inject path related environment variables to any batch command or script where directory or file path is used! The problem disappeared after downgrading back Environment Injector Plugin from 1.93.1 to 1.92.1
          Grigoriy Milman made changes -
          Resolution Original: Cannot Reproduce [ 5 ]
          Status Original: Closed [ 6 ] New: Reopened [ 4 ]
          Grigoriy Milman made changes -
          Attachment New: ConsoleOutput.PNG [ 35459 ]
          Attachment New: PropertiesContent.PNG [ 35460 ]

          Oleg Nenashev added a comment -

          gremlm chehrlic Please see the changelog for 1.93. It explicitly says the format of property parsing has changed (see the compatibility notes). Jenkins Update Manager also notifies admins about the incompatibility if they upgrade from the version below 1.93. From what I see in this issue, you just have not updated the configuration.

          Oleg Nenashev added a comment - gremlm chehrlic Please see the changelog for 1.93. It explicitly says the format of property parsing has changed (see the compatibility notes). Jenkins Update Manager also notifies admins about the incompatibility if they upgrade from the version below 1.93. From what I see in this issue, you just have not updated the configuration.
          Oleg Nenashev made changes -
          Assignee Original: Kohsuke Kawaguchi [ kohsuke ] New: Oleg Nenashev [ oleg_nenashev ]
          Oleg Nenashev made changes -
          Link New: This issue is related to JENKINS-39131 [ JENKINS-39131 ]

            Unassigned Unassigned
            chehrlic Christian Ehrlicher
            Votes:
            2 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: