Build fails or behaves differently in TeamCity but not locally
For the majority of build runners TeamCity runs the build process as a new process on the TeamCity agent machine, spawned under the TeamCity agent java process.
If a build fails or otherwise misbehaves in TeamCity but you believe it should not, please check that the build runs fine on the same machine as the TeamCity agent and under the same user that the agent is running, with the same environment variables and the same working directory.
If the TeamCity build agent is installed as a Windows service, try running the TeamCity agent from the command line. See also Windows Service limitations.
If this fixes the issue, you can try to figure out why running under the service is a problem for the build. Most often this is service-specific and is not related to TeamCity directly. Also, you can setup the TeamCity agent to be run from the console all the time (e.g. configure an automatic user logon and run the agent on the user logon).
Here are the detailed steps you can use to run a build from the command line:
Assuming you have a configured build in TeamCity which is failing, do the following:
- run the build in TeamCity and see it misbehaving
- disable the agent so that no other builds run on it. This can be done while the build is still in progress
- log in to the agent machine using the same user as the one running the TeamCity agent (check the right user in the machine processes list)
- stop the agent
- in a command line console, "cd" to the checkout directory of the build in question (the directory can be looked up in the beginning of the build log in TeamCity)
- run the build with a command line as you would do on a developer machine. This is runner-dependent. (For some runners you can look up the command line used by TeamCity in the build log, see also the logs\teamcity-agent.log agent log file for the command line used by TeamCity)
- if the build fails - investigate the reason as the issue is probably not TeamCity-related and should be investigated on the machine.
- if it runs OK, continue
- in the same console window "cd" to <TeamCity agent home>\bin and start TeamCity agent from there with the agent start command
- ensure the runner settings in TeamCity are appropriate and should generate the same command line as you used manually
- run the build in TeamCity selecting the agent in the Run custom build dialog
- when finished, enable the agent
If the build succeeds from the console but still fails in TeamCity, please use a command line runner in TeamCity to launch the same command as in the console. If it still behaves differently in TeamCity, most probably this is an environment or a tool issue.
If the command line runner works but the dedicated runner does not while the options are all the same, please create a new issue in our tracker detailing the case. Please attach all the build step settings, the build log, all agent logs covering the build, the command you used in the console to run the build and the full console output of the build.
Please sign in to leave a comment.