Metarunner created with Powershell hangs at the start of Powershell
Hello TeamCity Support,
I have a metarunner created with Powershell as follows:
------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<meta-runner name="RunProcess">
<description>Run Process with Timeout</description>
<settings>
<parameters>
<param name="ExecutablePath" value="%teamcity.build.checkoutDir%" />
<param name="Parameters" value="" />
<param name="Timeout in s" value="" />
</parameters>
<build-runners>
<runner name="Run Process" type="jetbrains_powershell">
<parameters>
<param name="jetbrains_powershell_bitness" value="x86" />
<param name="jetbrains_powershell_execution" value="STDIN" />
<param name="jetbrains_powershell_noprofile" value="true" />
<param name="jetbrains_powershell_script_code"><![CDATA[$params = '%Parameters%'
Write-Host "---------------------------------------------------"
Write-Host "Start RunProcess meta-runner"
Write-Host "Executable: %ExecutablePath%"
Write-Host "Parameters: %Parameters%"
Write-Host "Timeout: %Timeout in s%"
Write-Host "---------------------------------------------------"
If([string]::IsNullOrEmpty($params)){
$p = Start-Process "%ExecutablePath%" -PassThru -NoNewWindow
}
Else{
$p = Start-Process "%ExecutablePath%" $params -PassThru -NoNewWindow
}
$timeouted = $null
# time for timeout is in seconds!
$p | Wait-Process -Timeout %Timeout in s% -ea 0 -ev timeouted
If($timeouted){
Write-Host "Killing the process after timeout!"
Write-Host "##teamcity[buildStatus status='FAILURE' text='Process did not terminate in specified timeout!']"
$p.Kill()
}
$returnCode = $p.GetType().GetField("exitCode", "NonPublic,Instance").GetValue($p)
If(($p.hasExited) -and ($returnCode -ne 0) -and (!$timeouted)){
Write-Host "##teamcity[buildStatus status='FAILURE' text='Process terminated with exit code != 0']"
}]]></param>
<param name="jetbrains_powershell_script_mode" value="CODE" />
<param name="teamcity.step.mode" value="default" />
<param name="jetbrains_powershell_edition" value="Desktop" />
</parameters>
</runner>
</build-runners>
</settings>
</meta-runner>
-----------------------------------------------------------------------------------------------------------------------------------------------------
It hangs occasionally on agents with and without windows service. The logs are
Please sign in to leave a comment.
Hi Irin,
Please follow the steps here: https://confluence.jetbrains.com/display/TCD18/Common+Problems#CommonProblems-BuildworkslocallybutfailsormisbehavesinTeamCity
If it only happens during the meta runner, I'd recommend trying it as well on a build configuration (instead of meta runner) and seeing if there it works or fails as well.