4

teamcity 経由で実行しようとしている powershell スクリプトがあります。スクリプトは、コードのビルド元の git リポジトリに保存されます。スクリプトをスクリプト ファイルとして実行するように teamcity を設定しました

ビルド サーバーで powershell コマンドラインからスクリプトを実行すると、期待どおりに実行されます。teamcity から同じスクリプトを実行すると、次のようなエラーが発生します。

[16:04:25][Step 3/3] Get-Date : Cannot bind parameter 'Date'. Cannot convert value "–f" to type 
[16:04:25][Step 3/3] "System.DateTime". Error: "The string was not recognized as a valid DateTime. 
[16:04:25][Step 3/3] There is an unknown word starting at index 0."
[16:04:25][Step 3/3] At line:1 char:26
[16:04:25][Step 3/3] + Write-Output "$(Get-Date –f $timeStampFormat) - Upgrading Deployment: In 
[16:04:25][Step 3/3] progr ...
[16:04:25][Step 3/3] +                          ~~~~
[16:04:25][Step 3/3]     + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindin 
[16:04:25][Step 3/3]    gException
[16:04:25][Step 3/3]     + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerSh 
[16:04:25][Step 3/3]    ell.Commands.GetDateCommand
[16:04:25][Step 3/3]  

なぜこれが起こっているのでしょうか?

4

2 に答える 2

3

解決策は、本来あるべきものよりもはるかに簡単でした。teamcity には「スクリプト実行モード」と呼ばれるオプションがあり、スクリプトが期待どおりに実行されるようになると、これを変更しPut script into PowerShell stdin with "-Command -" argumentsました。Execute .ps1 script with "-File" argument

于 2013-05-07T15:01:23.710 に答える