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

An extra backslash is added from injected environment variable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: envinject-plugin
    • Labels:
      None
    • Environment:
      envinject-2.3.0
    • Similar Issues:

      Description

      **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

        Attachments

          Activity

          Hide
          orlo Tim Orlowski added a comment -

          I found this broke with 2.3.0 version of the plugin with the change for one of the two commits mentioned above. probably the "Escape paths for network shares (#146) @res0nance"
           
           Need to add a testcase for the use case where we want to have the value to be a directory without the drive.  If this testcase was there then this regression wouldn't have gone out.
           

          String content = "KEY1=\\Windows\\Temp";
          assertEquals("\\Windows\\Temp", gatherVars.get("KEY1"));

           

           

          the current code will currently evaluate it as  \\Windows\Temp

          Show
          orlo Tim Orlowski added a comment - I found this broke with 2.3.0 version of the plugin with the change for one of the two commits mentioned above. probably the "Escape paths for network shares ( #146 ) @res0nance"    Need to add a testcase for the use case where we want to have the value to be a directory without the drive.  If this testcase was there then this regression wouldn't have gone out.   String content = "KEY1=\\Windows\\Temp" ; assertEquals( "\\Windows\\Temp" , gatherVars.get( "KEY1" ));     the current code will currently evaluate it as  \\Windows\Temp

            People

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

              Dates

              Created:
              Updated: