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

Environment variable replacement on WINDOWS discard backslashes

    Details

    • Epic Link:
    • Similar Issues:

      Description

      Using Declarative Pipeline set environment:

          environment {

                      TEST="$WORKSPACE/test"

                      ...

                      SPEC='linux_x86-64'

                      }

      works fine on linux.

      On Windows 
      WORKSPACE=C:\Users\jenkins\workspace\openjdk_test_x86-64_windows
      TEST will be C:Usersjenkinsworkspaceopenjdk_test_x86-64_windows/test. That is saying passing $WORKSPACE to toString() return discard all backslashes.

      Tried using slash string TEST=/$WORKSPACE/ +'/test' got same issue.

       

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Turns out the issue is with environment variables that aren't defined in the Jenkinsfile, which is why my existing tests didn't catch this. But conveniently enough, this is fixed by the work for JENKINS-42753, I've added a test to the relevant PR, and it'll be included in the upcoming Declarative 1.2 release.

            Show
            abayer Andrew Bayer added a comment - Turns out the issue is with environment variables that aren't defined in the Jenkinsfile , which is why my existing tests didn't catch this. But conveniently enough, this is fixed by the work for JENKINS-42753 , I've added a test to the relevant PR, and it'll be included in the upcoming Declarative 1.2 release.
            Hide
            abayer Andrew Bayer added a comment -

            What version of Declarative do you have installed? I've got tests for this sort of thing in since JENKINS-42748, which went into 1.1.3. I don't have a Windows test env handy, so I can't verify that WORKSPACE gets handled correctly, but if I define an environment variable with backslashes, it does work fine...

            Show
            abayer Andrew Bayer added a comment - What version of Declarative do you have installed? I've got tests for this sort of thing in since JENKINS-42748 , which went into 1.1.3. I don't have a Windows test env handy, so I can't verify that WORKSPACE gets handled correctly, but if I define an environment variable with backslashes, it does work fine...
            Hide
            rkhalil Raul Khalil added a comment -

            it is not possible to put double backslashes we don´t define the variable. Is there any workaround for this?

            Show
            rkhalil Raul Khalil added a comment - it is not possible to put double backslashes we don´t define the variable. Is there any workaround for this?
            Hide
            davida2009 David Aldrich added a comment - - edited

            Have you tried double backslashes?  For example:

            VSMSBUILDCMD = 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsMSBuildCmd.bat'

             

            Show
            davida2009 David Aldrich added a comment - - edited Have you tried double backslashes?  For example: VSMSBUILDCMD = 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsMSBuildCmd.bat'  

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                sophiag Sophia Guo
              • Votes:
                4 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: