Search code examples
jenkinsjenkins-pipelinespecial-characters

Jenkins Pipeline: use Windows environment variable with '(' in it


In my Jenkins pipeline I want to access the Windows environment variable named "ProgramFiles(x86)". However, I do not know what syntax I have to use to make Jenkins pipeline understand that the '(x86)' is part of the environment variable name. I keep getting an error with for example "echo env.ProgramFiles(x86)

groovy.lang.MissingPropertyException: No such property: x86 for class: groovy.lang.Binding

I also tried

echo "${ProgramFiles(x86)}"

and

echo "${env.ProgramFiles(x86)}"

but no success there either.


Solution

  • you can use single quotes around the variable name see below example:

    echo "${env.'ProgramFiles(x86)'}"