How to change an existing environment variable (e.g. PATH) of windows

Hi

For all my build steps, i.e. my build process, I'd like to add something to the PATH environment variable and then use this variable in my build steps (which currently mostly consists of CMD-steps).

What I already tried is to define a ' Parameter' i.e. a Configuraton Parameter or a new Environement Variable. I tried something like in the attached screenshot, but this doesn't help.

As a workaround I'm currently doing the following in each of my CMD-steps:

SET PATH=.\myNewPath\.bin;%PATH%
//actual CMD command

Is there any way to accomplish this?


Thanks & Greetings
Patrick



Attachment(s):
Capture.PNG
7 comments
Comment actions Permalink

Hi Patrick,

Please use environment variable (defined using "env." prefix) parameter kind. All build parameters starting with "env." prefix (environment variables) are passed into the build's process environment (omitting the prefix). Find more details here.


0
Comment actions Permalink

Hi Alina

Your answer does not help for my question. I asked specifically how to change a variable and I don't see how your link answers that.

0
Comment actions Permalink

you can just set the env.PATH for the build configuration to the following value: C:\myDir;%env.PATH%

It should work

1
Comment actions Permalink

Thanks for your help.

But i doesn't work.

At the "Paraemters" Tab I set your variable.
When I run my build I get the following error:

Parameter "env.Path=.\node_modules\.bin;%env.PATH%" is not fully resolved, using as is.

And all my "CMD" steps won't work.

1
Comment actions Permalink

What OS do you have on this agent?

Also, can you please create a build configuration that a command line runner that outputs only the current value of PATH variable, like "declare -x | grep PATH". On this configuration try to do the same thing set parameter and check the build log for the PATH variable value. On linux please consider the case as well.

0
Comment actions Permalink

Sorry to resurrect an old post, but I'm running into this problems as well.

Agent is Windows 2012 R2.  Was setting env.PATH to a value of:
%NODE0.12_Prefix%%teamcity.agent.jvm.file.separator%bin%teamcity.agent.jvm.path.separator%%env.PATH%


It was working fine, until I installed Windows Updates, and Visual Studio 2015 onto the agent.  Now it stopped working. Before I got the exact result I expected, but now...

The env.Path parameter looks like this on the agent prior to running the build:

C:\Perl64\site\bin;C:\Perl64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Git\cmd;C:\Program Files\Perforce;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\doxygen\bin;C:\Users\Administrator\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\nodejs\;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Users\teamcity\AppData\Roaming\npm

Values passed to the build shows the env.PATH as mentioned above.

%NODE0.12_Prefix%%teamcity.agent.jvm.file.separator%bin%teamcity.agent.jvm.path.separator%%env.PATH%

The "Actual Parameters on Agent" then appears as this for env.Path:

C:\Node.js\0.12.7-x64\bin;%env.Path%


Does it maybe have something to do with the length of the
Prior to agent update, this was the path on the agent:

C:\Perl64\site\bin;C:\Perl64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Git\cmd;C:\Program Files\Perforce;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\doxygen\bin;C:\Users\Administrator\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\nodejs\;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Users\teamcity\AppData\Roaming\npm

Well below the limit of 2048 Windows has on the length of the Path environment variable, but maybe some other limit is being hit?

0
Comment actions Permalink

Shortening the path had no effect. Going to test if it's the system updates or VS2015 that caused it, or something else as I recall now that I also ran the windows Disk Cleanup and cleaned up 1GB of old system updates.  This time testing each step along the way to narrow down which one caused the change in behavior.  Hopefully I can have more details on an actual cause soon.

Edit:
Point of failure was installation of VS2015,  granted that's a fairly large installation, but that's when it all broke.  I need to take off for the day, but tomorrow I'll test shortening the path further. If no luck there, I'm going to see if just installing .NET 4.6 causes this.

0

Please sign in to leave a comment.