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

An extra backslash is added from injected environment variable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • envinject-plugin
    • None
    • envinject-2.3.0

      **Sample code and veriables.

      Properties Content:

       

      TEMPDRIVE=C:
      TEMPDIR=\\Windows\\TEMP
      

       

       

      Pipeline Script:

       

      node {
       int rc = bat returnStatus: true, script: """
        set TEMPDRIVE=${env.TEMPDRIVE}
        set TEMPDIR=${env.TEMPDIR}
        %TEMPDRIVE% & cd %TEMPDIR%
        echo %CD%
      """
       }
      

       

       

      Results:

      [Pipeline] {
      [Pipeline] bat
       C:\Program Files (x86)\Jenkins\workspace\testpath>set TEMPDRIVE=C:
       C:\Program Files (x86)\Jenkins\workspace\testpath>set TEMPDIR=\\Windows\Temp 
       C:\Program Files (x86)\Jenkins\workspace\testpath>C:   & cd \\Windows\Temp 
      '\\Windows\Temp'
      CMD does not support UNC paths as current directories.
      C:\Program Files (x86)\Jenkins\workspace\testpath>echo C:\Program Files (x86)\Jenkins\workspace\testpath 
      C:\Program Files (x86)\Jenkins\workspace\testpath
      [Pipeline] }
      

       

      Expected Result:

       

      [Pipeline]
      { 
      [Pipeline] bat 
       C:\Program Files (x86)\Jenkins\workspace\testpath>set TEMPDRIVE=C:
       C:\Program Files (x86)\Jenkins\workspace\testpath>set TEMPDIR=\Windows\Temp 
       C:\Program Files (x86)\Jenkins\workspace\testpath>C: & cd \Windows\Temp 
       C:\Windows\Temp>echo C:\Windows\Temp 
       C:\Windows\Temp
      [Pipeline] 
      }
       
      

      **

       

       

      It seems it is due to the following update.

       https://github.com/jenkinsci/envinject-plugin/commit/2c44f59208ff4414e2de34e39cc0eb50b55794d1#diff-5e1fb35da7722bd6b60a0613ba442ad6

      https://github.com/jenkinsci/envinject-plugin/commit/6a272b70a1364af2d0894c1472f26ad5d5a02718#diff-5e1fb35da7722bd6b60a0613ba442ad6

            Unassigned Unassigned
            roki0103b Hiroki Hiyane
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: