1
votes

In my nant script I retrieve my environment variable in this way:

property name="ProjectSolutionPath" value="${environment::get-variable('MAIN_PROJECT_PATH')}"

but when I run it through jenkins using nant as build step I got an error like this.

Expression: ${environment::get-variable('MAIN_PROJECT_PATH')}
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Environment variable "MAIN_PROJECT_PATH" does not exist.

Is there configuration for this? so that Jenkins will recognize environment variables access by my nant script?

Help is greatly appreciated.

1
What environment is this? Windows? If Windows then it might be worth checking to see if the environment variable is visible to the SYSTEM account (which is the user that Jenkins runs under). - Jane

1 Answers

2
votes

Make sure you define this environment variable in "System variables".

Since the Jenkins process usually runs as "NT AUTHORITY\SYSTEM" user, the environment variables associated with your user account do not get appended to the env-vars of the process.

I've seen this answer on how to add env-vars to a Jenkins build (though I don't like spawning a cmd line process), if you do not want to use sys-env-vars.