Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkins pipeline can't set correct environment variables on windows #41

Closed
sophia-guo opened this issue May 24, 2017 · 1 comment
Closed
Assignees
Labels

Comments

@sophia-guo
Copy link
Contributor

Backslash is discarded when interpolated in groovy string.
Environment variable JAVA_BIN="$WORKSPACE/openjdkbinary/j2sdk-image/jre/bin" ( OPENJDK_TEST="$WORKSPACE/openjdk-test") can not be set up correctly.

On Windows WORKSPACE=C:\Users\jenkins\workspace\openjdk_test_x86-64_windows $WORKSPACE is interpolated as C:Usersjenkinsworkspaceopenjdk_test_x86-64_windows.

@karianna karianna added the bug label May 24, 2017
@sophia-guo
Copy link
Contributor Author

sophia-guo commented May 24, 2017

As backward slash is an escape character for groovy String include '\'
will get compiling failure : GroovyUserScript: 1: unexpected char: '\'

Replacing ${WORKSPCE} in string is to evaluate its string representation by calling it toString() method. I believe environment variables is returned at Declarative jenkins environment section with "\" discarded. Create an issue Environment variable replacement on WINDOWS discard backslashes : https://issues.jenkins-ci.org/browse/JENKINS-44482. I have searched a little bit, there is an similar but not same one issue :https://issues.jenkins-ci.org/browse/JENKINS-31144. Seem won't fix.

For now I have two choice:

  1. Hard code environment variable for windows using slashes
    JAVA_BIN='C:/Users/jenkins/workspace/openjdk_test_x86-64_windows/openjdkbinary/j2sdk-image/jre/bin'

  2. Using step

withEnv(["OPENJDK_TEST=${WORKSPACE}/openjdk_test_x86-64_windows/openjdk-test"]) {
}

The second choice will require using withENV() for each stage and all relate steps have to be inside this withEnv block.

karianna added a commit that referenced this issue May 30, 2017
issue #41 issue #45 Enable tests on windows
@sophia-guo sophia-guo self-assigned this May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants