- I'm not allowed to install TeamCity agent there
- I'm not allowed to install any software like SSH on target server.
First i tried to use PsExec but I had lot's of problems with capturing output and passing it to the TeamCity build agent. The ultimate solution turns out to be PowerShell with remote execution.
I used invoke-command but next problem raised with passing parameters to the script block. Fortunately help came from StackOverflow, and finally I manage do create working solution.
In first step I'm preparing parameterized script block. In this example I will run my DeployCmd with couple of parameters. Additionally I'm redirecting error to standard output since I will be checking output on TeamCity side.
$deploymentPackageDeployScript = {
param( $DeployCmd, $PkgName, $PkgFlavour, $PkgDeplyProfile )
& $DeployCmd -action:deploy "-applicationPrototype:$PkgName"
"-applicationFlavour:$PkgFlavour" "-deploymentProfileName:$PkgDeplyProfile" 2>&1
}
Then I'm executing script block on remote machine
$output = invoke-command -ComputerName $remoteMachineName
-ScriptBlock $deploymentPackageDeployScript
-ArgumentList $deployCmd,$deploymentPackageName,
$applicationFlavour,$profileName
write-host $output
Everything is stored in ps script in TFS.
On TeamCity side, I have PowerShell task defined.
Output is checked using Build Failure Conditions.
In this particular case, I'm just looking for exact text in build log, but regular expressions can be also used.
We have been running this for couple of months, and it is working very nice.
Have fun.
No comments:
Post a Comment