We have TeamCity and on the [Runner: Command Line]
of the [Build Configuration]
page, there is a [Command Parameter]
field %system.teamcity.build.workingDir%
My question is where does TeamCity get this value from as when i look at the System Properties of the Agent i do not see it has been set.
%system.teamcity.build.workingDir%
does not appear in the list of [System Properties]
or [Environment Variables]
The build working directory is the directory set as current for the build process. By default, this is the same directory as the build checkout directory.
Last modified: 30 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.
Where are you looking? It is listed along with other system properties:
@Snahider - a build at any point runs only on one agent. So %system.teamcity.build.workingDir%
will be set to the current build's working dir. It is not same as %system.agent.work.dir%
which is the parent of the checkout directory for each build.
For example if you have your agent installed in C:\BuildAgent
the %system.agent.work.dir%
will be C:\BuildAgent\work
whereas %system.teamcity.build.workingDir%
will be something like C:\BuildAgent\work\8b0fde2bf2d2efc0
if you have not specified the checkout directory in VCS settings or if you have set it, to say wd
it will be C:\BuildAgent\work\wd
One more thing is that, if in the build step step you change the working directory, to say Examples
, %system.teamcity.build.workingDir%
will, as the name suggests, point to that - C:\BuildAgent\work\wd\Examples
So %system.teamcity.build.workingDir%
can change depending on what is happening, while %system.agent.work.dir%
will remain same for an agent. Hope this explains the difference.
%system.teamcity.build.workingDir% documentation says:
The build working directory is the directory set as current for the build process. By default, this is the same directory as the Build Checkout Directory. If the build script needs to run from a location other than the checkout directory, then you can specify it explicitly using the Working Directory field on the settings page of the build runner.
If you have the WebServer and only on Agent in the same machine that directory is the same as the %system.agent.work.dir%
http://confluence.jetbrains.net/display/TCD5/Agent+Work+Directory
In my windows box is C:/Users/[user]/.BuildAgent/work.
if you have multiple agents i dont know what will be the directory. I recommend you to use %system.agent.work.dir% instead of %system.teamcity.build.workingDir%.
You can test the value of any variable using the same "command line build": write the variable in the "Command Parameters" input and run the build, you can see the real value in the logs when the build finshed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With