Error when trying to execute powershell script via "Command line runner"
Hi! I am unable to execute a powershell script using the "command line runner".
The command I am trying to run is: 'powershell -command ./myfile.ps1' (I wrapped the command in a bat-file, but I got the same error, the stack trace below originates from when I tried with the bat-file). Like I said, this command runs fine on the server
The command works fine if I run it directly on the server. What happens is that the build process never finishes and I have to manually stop it. Having looked through the log files, I found the following stacktrace in "teamcity-agent.log" found in my buildagent-logs directory:
INFO - jetbrains.buildServer.AGENT -
INFO - jetbrains.buildServer.AGENT - Found runner simpleRunner for 111
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.FireBuildStartedStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CleanBuildCheckoutDirectoryIfNeededStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CleanBuildTempDirectoryStage
INFO - s.CleanBuildTempDirectoryStage - Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
INFO - rectories.DirectoryCleanerImpl - Move directory C:\TeamCity\buildAgent\temp\buildTmp to C:\TeamCity\buildAgent\temp\.old\buildTmp_14 for cleaning
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CleanAgentTempDirectoryStage
INFO - rectories.DirectoryCleanerImpl - Move directory C:\TeamCity\buildAgent\temp\agentTmp to C:\TeamCity\buildAgent\temp\.old\agentTmp_14 for cleaning
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CreateAgentTempDirectoryStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CreateCheckoutDirectoryStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CreateBuildTempDirectoryStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.DirectoryCleanerForceClean
INFO - ges.DirectoryCleanerForceClean - Free space under build checkout directory is 10gb
INFO - ges.DirectoryCleanerForceClean - Free space under temp is 10gb
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.LogCheckoutDirectoryStage
INFO - jetbrains.buildServer.AGENT - Checkout directory: C:\TeamCity\buildAgent\work\58f29c7047f617a4
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CheckoutSourcesStage
INFO - jetbrains.buildServer.AGENT - Getting sources...
INFO - jetbrains.buildServer.AGENT - Sources updated for < 1s
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.AppendBuildParametersFromFileStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.ReplaceReferencesInAtrifactDependenciesStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.DownloadDependenciesStage
INFO - jetbrains.buildServer.AGENT - Finished resolving artifacts
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.SavePropertiesToFilesStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CreateBuildWorkingDirectoryStage
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.FireBeforeRunnerStartedStage
INFO - gent.impl.BuildRunTimeoutTimer - Build execution timeout is set to: 0
INFO - rver.agent.impl.BuildRunAction - Call stage jetbrains.buildServer.agent.impl.runStages.CallRunnerStage
INFO - impl.runStages.CallRunnerStage - Start actual runner for build 111 simpleRunner
INFO - impl.runStages.CallRunnerStage - -
INFO - nner2.OsProcessHandlerListener - C:\builds\mysite.se\DeployScripts\run.bat
INFO - rocesses.ProcessTreeTerminator - Use jetbrains.buildServer.processes.ProcessTreeTerminatorWindows
INFO - processes.VisitableProcessTree - Visited process: PID: 2872 PPID: 2308 CMD: cmd.exe
INFO - processes.VisitableProcessTree - Visited process: PID: 3520 PPID: 2872 CMD: powershell.exe
INFO - stacktraces.agent.DoThreadDump - Threaddumps: Running processes
PID: 2872 PPID: 2308 CMD: cmd.exe
PID: 3520 PPID: 2872 CMD: powershell.exe
INFO - nt.win32.DumpDotNetProcessList - emumerate .NET processes: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.DotNet.x86.exe /processes
INFO - nt.win32.DumpDotNetProcessList - Injector result code: 0
INFO - nt.win32.DumpDotNetProcessList - Injector stdoutput: TeamCity .NET Stacktrace utility. Copyright (C) JetBrains s.r.o. 2007-2008
3520
2924
1216
1176
1116
INFO - nt.win32.DumpDotNetProcessList - Injector stderror :
INFO - .agent.win32.Win32DoThreadDump - Dump stacktrace for cmd.exe pid=2872
INFO - .agent.win32.Win32DoThreadDump - Dump stacktrace for powershell.exe pid=3520
INFO - .win32.DumpProcessCallInjector - Injector Start dump stacktraces: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.exe 2872 cmdLine C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12119.output
ERROR - .win32.DumpProcessCallInjector - Injector Start dump stacktraces: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.exe 2872 cmdLine C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12119.output
ERROR - .win32.DumpProcessCallInjector - Injector result code: -1
ERROR - .win32.DumpProcessCallInjector - Injector stdoutput:
ERROR - .win32.DumpProcessCallInjector - Injector stderror :
WARN - .win32.DumpProcessCallInjector - java.io.FileNotFoundException: C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12119.output (The system cannot find the file specified)
java.io.FileNotFoundException: C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12119.output (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at com.intellij.openapi.util.io.FileUtil.loadFileText(FileUtil.java:172)
at com.intellij.openapi.util.io.FileUtil.loadFileText(FileUtil.java:167)
at jetbrains.buildServer.stacktraces.agent.win32.DumpProcessCallInjector.dumpStacktrace(DumpProcessCallInjector.java:56)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace$1.run(DumpStackTrace.java:60)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace.safeDo(DumpStackTrace.java:39)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace.dumpStacktrace(DumpStackTrace.java:58)
at jetbrains.buildServer.stacktraces.agent.DoThreadDump$2.call(DoThreadDump.java:92)
at jetbrains.buildServer.stacktraces.agent.DoThreadDump$2.call(DoThreadDump.java:90)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
INFO - .win32.DumpProcessCallInjector - Injector Start dump stacktraces: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.exe 3520 cmdLine C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12120.output
INFO - acktraces.agent.nix.JdkLocator - Looking for JSTACK in agent-running jvm...
ERROR - .win32.DumpProcessCallInjector - Injector Start dump stacktraces: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.exe 3520 cmdLine C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12120.output
INFO - acktraces.agent.nix.JdkLocator - Lookup for JSTACK. Found: jstack.exe
ERROR - .win32.DumpProcessCallInjector - Injector result code: -1
INFO - acktraces.agent.nix.JdkLocator - Looking for JSTACK in agent-running jvm...
ERROR - .win32.DumpProcessCallInjector - Injector stdoutput:
INFO - acktraces.agent.nix.JdkLocator - Lookup for JSTACK. Found: jstack.exe
ERROR - .win32.DumpProcessCallInjector - Injector stderror :
INFO - tacktraces.agent.nix.JStackRun - jstack call: jstack.exe 2872
WARN - .win32.DumpProcessCallInjector - java.io.FileNotFoundException: C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12120.output (The system cannot find the file specified)
java.io.FileNotFoundException: C:\TeamCity\buildAgent\temp\agentTmp\teamCity.cmdLine.1255609859059.12120.output (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at com.intellij.openapi.util.io.FileUtil.loadFileText(FileUtil.java:172)
at com.intellij.openapi.util.io.FileUtil.loadFileText(FileUtil.java:167)
at jetbrains.buildServer.stacktraces.agent.win32.DumpProcessCallInjector.dumpStacktrace(DumpProcessCallInjector.java:56)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace$1.run(DumpStackTrace.java:60)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace.safeDo(DumpStackTrace.java:39)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace.dumpStacktrace(DumpStackTrace.java:58)
at jetbrains.buildServer.stacktraces.agent.DoThreadDump$2.call(DoThreadDump.java:92)
at jetbrains.buildServer.stacktraces.agent.DoThreadDump$2.call(DoThreadDump.java:90)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
INFO - .win32.DumpProcessCallInjector - Injector Start dump stacktraces: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.exe 2872 stacktrace C:\TeamCity\buildAgent\temp\agentTmp\teamCity.stacktrace.1255609859059.15921.output
INFO - .win32.DumpProcessCallInjector - Injector Start dump stacktraces: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.DotNet.x86.exe /stacktrace /pid=3520 /output=C:\TeamCity\buildAgent\temp\agentTmp\teamCity.teamCity.dotNet.1255609859075.12622.output
ERROR - .win32.DumpProcessCallInjector - Injector Start dump stacktraces: C:\TeamCity\buildAgent\bin\..\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.exe 2872 stacktrace C:\TeamCity\buildAgent\temp\agentTmp\teamCity.stacktrace.1255609859059.15921.output
ERROR - .win32.DumpProcessCallInjector - Injector result code: -1
ERROR - .win32.DumpProcessCallInjector - Injector stdoutput:
ERROR - .win32.DumpProcessCallInjector - Injector stderror :
WARN - .win32.DumpProcessCallInjector - java.io.FileNotFoundException: C:\TeamCity\buildAgent\temp\agentTmp\teamCity.stacktrace.1255609859059.15921.output (The system cannot find the file specified)
java.io.FileNotFoundException: C:\TeamCity\buildAgent\temp\agentTmp\teamCity.stacktrace.1255609859059.15921.output (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at com.intellij.openapi.util.io.FileUtil.loadFileText(FileUtil.java:172)
at com.intellij.openapi.util.io.FileUtil.loadFileText(FileUtil.java:167)
at jetbrains.buildServer.stacktraces.agent.win32.DumpProcessCallInjector.dumpStacktrace(DumpProcessCallInjector.java:56)
at jetbrains.buildServer.stacktraces.agent.win32.Win32JavaJStackOrStacktraceCall.dumpStacktrace(Win32JavaJStackOrStacktraceCall.java:40)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace$2.run(DumpStackTrace.java:68)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace.safeDo(DumpStackTrace.java:39)
at jetbrains.buildServer.stacktraces.agent.win32.DumpStackTrace.dumpStacktrace(DumpStackTrace.java:66)
at jetbrains.buildServer.stacktraces.agent.DoThreadDump$2.call(DoThreadDump.java:92)
at jetbrains.buildServer.stacktraces.agent.DoThreadDump$2.call(DoThreadDump.java:90)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
INFO - .win32.DumpProcessCallInjector - Injector result code: 0
I also found a system error occurring at the same time using the eventvwr:
"Generate Activation Context failed for C:\TeamCity\buildAgent\plugins\stacktracesPlugin\bin\x86\JetBrains.TeamCity.Injector.exe. Reference error message: The manifest file contains one or more syntax errors."
Finally, if i view the thread dump when I am attemting to run the build configuration, I get the following stack trace:
Failed to get command line of the process.
2009-10-15 14:30:59
Stack trace depth is set to show all frames
Thread id=256 priority=12 state=Wait reason=UserRequest
Thread id=1756 priority=9 state=Wait reason=UserRequest
at System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle waitHandles, System.Int32 millisecondsTimeout, System.Boolean exitContext)
at System.Management.Automation.Internal.ObjectStream.WaitRead()
at System.Management.Automation.Internal.ObjectStream.Read(System.Int32 count)
at System.Management.Automation.Internal.ObjectStream.Read()
at System.Management.Automation.Internal.ObjectReader.Read()
at System.Management.Automation.Internal.Pipe.Retrieve()
at System.Management.Automation.CommandProcessorBase.Read()
at System.Management.Automation.ShellFunctionCommandProcessor.ProcessRecord()
at System.Management.Automation.CommandProcessorBase.DoExecute()
at System.Management.Automation.Internal.PipelineProcessor.Inject(System.Object input, System.Boolean enumerate)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object input, System.Collections.Hashtable errorResults, System.Boolean enumerate)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecute(System.Array input, System.Collections.Hashtable errorResults)
at System.Management.Automation.Internal.PipelineProcessor.Execute(System.Array input)
at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object state)
at System.Threading.ExecutionContext.runTryCode(System.Object userData)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state)
at System.Threading.ThreadHelper.ThreadStart()
Thread id=2016 priority=8 state=Wait reason=Executive
at
at System.IO.FileStream.ReadFileNative(Microsoft.Win32.SafeHandles.SafeFileHandle handle, System.Byte bytes, System.Int32 offset, System.Int32 count, System.Threading.NativeOverlapped overlapped, System.Int32 hr)
at System.IO.FileStream.ReadCore(System.Byte buffer, System.Int32 offset, System.Int32 count)
at System.IO.FileStream.Read(System.Byte array, System.Int32 offset, System.Int32 count)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at System.IO.TextReader+SyncTextReader.ReadLine()
at Microsoft.PowerShell.WrappedDeserializer..ctor(Microsoft.PowerShell.SerializationDataFormat dataFormat, System.String streamName, System.IO.TextReader input)
at Microsoft.PowerShell.Executor.ExecuteCommandAsyncHelper(System.Management.Automation.Runspaces.Pipeline tempPipeline, System.Exception exceptionThrown, Microsoft.PowerShell.ExecutorExecutionOptions options)
at Microsoft.PowerShell.ConsoleHost.InitializeRunspace(System.String initialCommand, System.Boolean skipProfiles, System.Collections.ObjectModel.Collection initialCommandArgs)
at Microsoft.PowerShell.ConsoleHost.DoRunspaceLoop(System.String initialCommand, System.Boolean skipProfiles, System.Collections.ObjectModel.Collection initialCommandArgs)
at Microsoft.PowerShell.ConsoleHost.Run(System.String bannerText, System.String helpText, System.Boolean isPrestartWarned, System.String args)
at Microsoft.PowerShell.ConsoleHost.Start(System.Management.Automation.Runspaces.RunspaceConfiguration configuration, System.String bannerText, System.String helpText, System.String preStartWarning, System.String args)
at Microsoft.PowerShell.ConsoleShell.Start(System.Management.Automation.Runspaces.RunspaceConfiguration configuration, System.String bannerText, System.String helpText, System.String preStartWarning, System.String args)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String consoleFilePath, System.String args)
at System.RuntimeMethodHandle.InvokeMethodFast(System.Object target, System.Object arguments, System.Signature sig, System.Reflection.MethodAttributes methodAttributes, System.RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture, System.Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture)
The server is a Windows 2003.
Please sign in to leave a comment.
Please take a look at this issue: http://youtrack.jetbrains.net/issue/TW-6021
As for command line runner - I would suggest to try the latest TeamCity EAP, I think this problem is fixed there.