Trouble with Powershell and NAnt during build
I'm trying out Teamcity as a possible replacement for our current CruiseControl installation. Everything was going great until I got the agent up and running:
My NAnt build has an EXEC task for a powershell build. Agent will hang indefinitely( > 30 minutes) on this task without moving. Same task works fine if I execute NAnt from the commandline(even from the Work directory on the Agent).
Any ideas?
Please sign in to leave a comment.
What version of TeamCity do you use?
What version of NAnt is used?
Could you please send me hanging part of the script to reproduce.
Could you please try to capture logs from .NET part of TeamCity. For doing it please do the following:
- select some build agent
- open /plugins/dotnet-plugin/bin - backup teamcity-log4net.xml - in teamcity-log4net-debug.xml uncomment the line containing '' - rename teamcity-log4net-debug.xml to teamcity-log4net.xml - run the build. all log files will be places to ]]>/tmp/buildTmp/TeamCity.NET folder.
Please attach all the files from that folder.
Thanks!
Eugene,
TeamCity Version - 3.1.1(build 6828)
NAnt version .85
Hangs on this target:
I've attached the log file that was generated by the steps you detailed.
Thanks,
-Pete
Attachment(s):
debug.zip
Thanks. Seems array is broken.
You may email it to eugene[dot]petrenko]at[jetbrains.com
What is done under that powershell call? Does it produces much output?
The powershell call is a DB build script. It generates about 300 lines of messages during the build process. Last week I tested without the status messages being printed by the script and it failed in the exact same fashion.
-Pete
I got the logs.
Could you please try taking thread dumps feature for that hanging build. What is shown for NAnt process?
Thanks!
Two processes listed in the thread dump, dumps below:
Peter,
I had something similar happen to me in Ant when I was trying to use ]]> task without the full path to the executable for perl. I ended up having to write something like this:
I don't know if it would work in NAnt though.
Hope this helps,
Oleg.
Oleg,
Thanks for the tip, but unfortunately specifying the entire path didn't seem to have an affect.
-Pete
So according to logs, I see that NAnt process is waiting for powershell to finish, while powershell is trying to read some file.
What user is used for build agent service? Does that user have enough rights to work? Sometimes SYSTEM accound does not match.
Could you please try settings some working folder for the script.
Let's replace powershell script with 'hello world' like script. Does that still hang?
Thanks!
I have created the following test script, called "test.ps1":
I created a new task in my NAnt.build file:
I modified the build agent to run the new task, same behavior, hangs indefinitely.
I also checked the permissions for the service, service is set to run under SYSTEM, SYSTEM has full privileges on the BuildAgent directory and all subdirectories.
-Pete
Thanks!
Could you please try running it under some real user on the machine. There were several issue on SYSTEM account used for build agent.
Created a new user with administrator privileges on the machine, set build agent service to run under the new user, restarted the service.
Same behavior, hangs on the hello.world task.
Maybe the builder in TeamCity cannot find "..\script\test.ps1" because it starts in a different directory from the one you start in by hand?
Peter,
Did you ever find a solution to the problem of powershell hanging waiting for input? I've managed to run into the same issue, and my thread trace looks identical. PowerShell.exe seems to be waiting for input.
I've actually managed to work around the issue by writing a batch file and causing TC to execute that instead of powershell.exe directly, and in the batch file I have something like this:
@echo off
echo whatsthedeal | powershell.exe -noninteractive -noprofile -nologo -command "& 'my_script.ps1'"
But that's not ideal for obvious reasons.
Issue was never resolved. I switched to Cruise Control.
We created the issue to address the problem. Eugene will look into it to investigate if this powershell limitation can be workarounded.
Note than I'm executing powershell.exe directly using the command line runner, and I've also tried executing a batch file instead that launched powershell.exe instead. Neither worked. The only way I got it to work was to put in my batch file something like:
echo something_nonsensical_here | powershell.exe {command line parameters here}
... in which case it worked. I ended up working around the issue by writing a small replacement tool for powershell.exe that would execute my powershell script.