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

Cannot escape dollar sign in Windows environment

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • envinject-plugin
    • None
    • EnvInject 1.71

      Fix JENKINS-13566 introduced the following bug.

      I can no longer escape the dollar sign value on a Windows environment.

      e.g.
      foobar1=foo\$bar
      foobar2=foo$bar

      Respectively becomes:
      foo\$bar
      foo

      The value "foo$bar" cannot be achieved.

      My opinion is that the "escaping" behaviour should be the same regardless of operating system. I propose that the JENKINS-13566 changes should be reverted, and that Vincent Latombe should double escape their path.
      i.e.
      C:\DOCUME~1\\$NCESE~1\LOCALS~1\Temp

          [JENKINS-15751] Cannot escape dollar sign in Windows environment

          I added a comment in the previous issue.
          I asked Vincent what is his opinion?
          However, do you have a specific use case when you need to escape dollars?

          Gregory Boissinot added a comment - I added a comment in the previous issue. I asked Vincent what is his opinion? However, do you have a specific use case when you need to escape dollars?

          Nick Grealy added a comment -

          Hi Gregory,

          Sorry for the late reply (I don't have access to a windows Jenkins instance at the moment), but I'll use a similar use case to Vincent's:

          — User Story —

          As a Jenkins user
          I want to use the environment variable name "win_sys_path" with a value "\\127.0.0.1\c$\WINDOWS"
          So that I can access a windows system folder from a remote computer.

          — User Scenarios —

          Global: Given a Jenkins Windows instance

          Given the environment variable "win_sys_path" with value "\\127.0.0.1\c$\WINDOWS"
          When I echo the variable "win_sys_path"
          Then the value should be "\\127.0.0.1\c"

          Given the environment variable "win_sys_path" with value "\\127.0.0.1\c\$\WINDOWS"
          When I echo the variable "win_sys_path"
          Then the value should be "\\127.0.0.1\c$\WINDOWS"

          Given the environment variable "win_sys_path" with value "\\127.0.0.1\c\\$\WINDOWS"
          When I echo the variable "win_sys_path"
          Then the value should be "\\127.0.0.1\c\$\WINDOWS"

          Hope that makes sense.

          Nick

          Nick Grealy added a comment - Hi Gregory, Sorry for the late reply (I don't have access to a windows Jenkins instance at the moment), but I'll use a similar use case to Vincent's: — User Story — As a Jenkins user I want to use the environment variable name "win_sys_path" with a value "\\127.0.0.1\c$\WINDOWS" So that I can access a windows system folder from a remote computer. — User Scenarios — Global: Given a Jenkins Windows instance Given the environment variable "win_sys_path" with value "\\127.0.0.1\c$\WINDOWS" When I echo the variable "win_sys_path" Then the value should be "\\127.0.0.1\c" Given the environment variable "win_sys_path" with value "\\127.0.0.1\c\$\WINDOWS" When I echo the variable "win_sys_path" Then the value should be "\\127.0.0.1\c$\WINDOWS" Given the environment variable "win_sys_path" with value "\\127.0.0.1\c\\$\WINDOWS" When I echo the variable "win_sys_path" Then the value should be "\\127.0.0.1\c\$\WINDOWS" Hope that makes sense. Nick

          Nick Grealy added a comment -

          Update: ignore the "Global: Given a Jenkins Windows instance", this same functionality should apply on ALL operating systems (but in this case, specifically on Windows).

          Nick Grealy added a comment - Update: ignore the "Global: Given a Jenkins Windows instance", this same functionality should apply on ALL operating systems (but in this case, specifically on Windows).

          Nick Grealy added a comment -

          Looking at the code, the correct way to escape a dollar sign character, is by using two dollar sign characters.

          Using the following versions:
          Jenkins: 1.581
          Environment Injector Plugin: 1.90

          My test:

          Properties Content:
          test1=C:\DOCUME~1\$NCESE~1\LOCALS~1\Temp
          test2=\\127.0.0.1\c$\WINDOWS
          test3=Pas$word
          test4=C:\DOCUME~1\$$NCESE~1\LOCALS~1\Temp
          test5=\\127.0.0.1\c$$\WINDOWS
          test6=Pas$$word

          Windows Command:
          @echo off
          echo %test1%
          echo %test2%
          echo %test3%
          echo %test4%
          echo %test5%
          echo %test6%

          Output:
          C:\DOCUME~1\$NCESE~1\LOCALS~1\Temp
          \\127.0.0.1\c$\WINDOWS
          Pas$word
          C:\DOCUME~1\$NCESE~1\LOCALS~1\Temp
          \\127.0.0.1\c$\WINDOWS
          Pas$word

          Looks correct... closing this issue.

          Nick Grealy added a comment - Looking at the code , the correct way to escape a dollar sign character, is by using two dollar sign characters. Using the following versions: Jenkins: 1.581 Environment Injector Plugin: 1.90 My test: Properties Content: test1=C:\DOCUME~1\$NCESE~1\LOCALS~1\Temp test2=\\127.0.0.1\c$\WINDOWS test3=Pas$word test4=C:\DOCUME~1\$$NCESE~1\LOCALS~1\Temp test5=\\127.0.0.1\c$$\WINDOWS test6=Pas$$word Windows Command: @echo off echo %test1% echo %test2% echo %test3% echo %test4% echo %test5% echo %test6% Output: C:\DOCUME~1\$NCESE~1\LOCALS~1\Temp \\127.0.0.1\c$\WINDOWS Pas$word C:\DOCUME~1\$NCESE~1\LOCALS~1\Temp \\127.0.0.1\c$\WINDOWS Pas$word Looks correct... closing this issue.

          Nick Grealy added a comment -

          Correct way to escape '$' is by using '$$'.

          Nick Grealy added a comment - Correct way to escape '$' is by using '$$'.

          Andrew Gray added a comment -

          See my comment on JENKINS-13157. It appears if it is a TRAILING $ then two $ characters doesn't work on Windows

          Andrew Gray added a comment - See my comment on JENKINS-13157 . It appears if it is a TRAILING $ then two $ characters doesn't work on Windows

            nickg Nick Grealy
            nickg Nick Grealy
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: