Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does a TeamCity build agent get its path environment from?

I'm trying to set up TeamCity to build my project, but my psake buildscript fails, with the reason being narrowed down to its inability to find the git executable, which is supposed to be on the path. When I start a PowerShell and execute the thing by myself, everything works fine.

The content of the Path environment variable (as shown in the System variables list in the windows Environment Variables dialog, as well as the registry at HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment\Path) is

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Git\cmd 

yet TeamCity says its env.Path is just

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Windows\System32\WindowsPowerShell\v1.0 

I have restarted the computer (multiple times) which does not help whatsoever.

Why is the TeamCity build agent's PATH variable different from the system default, and how can I fix it?

like image 849
erikkallen Avatar asked Jan 11 '12 22:01

erikkallen


People also ask

How does TeamCity agent work?

A TeamCity build agent is a piece of software which listens for the commands from the TeamCity server and starts the actual build processes. It is installed and configured separately from the TeamCity server.

What is parameter in TeamCity?

Last modified: 10 August 2022. Build parameters are name-value pairs, defined by a user or provided by TeamCity, which can be used in a build. They help flexibly share settings and pass them to build steps.


2 Answers

I ran into this same issue and only needed to restart the Team City Build Agent Service to pick up changes to the PATH variable.

like image 93
Sean Avatar answered Sep 22 '22 12:09

Sean


You can expand the path for a build agent by adding a build parameter named "env.PATH" with the following value on Mac OS and Linux.

%env.PATH%:/my/path 

On Windows use ";" instead of ":" as the path delimiter.

You can also add the following to conf/buildAgent.properties in your build agent installation directory.

env.PATH=%env.PATH%:/my/path 

(There is a comment at the bottom of the file that shows how to set environment vars.)

like image 38
mockaroodev Avatar answered Sep 19 '22 12:09

mockaroodev