我有以下部分代码(从较大的脚本中提取):
Write-Output "Syncing $directory"
Push-Location $directory
git pull origin $branch
$directoryName = [IO.Path]::GetFileName($directory)
git log -n 1 --pretty=format:"%H %cd %aN%n%B" --date=short > "..\$directoryName.lastcommit.txt"
Pop-Location
在Windows Azure WebJob中运行时,偶尔(约50%的几率)会产生错误:
[05/06/2014 22:20:43 > e5e3ee: INFO] Syncing D:\home\site\!roslyn-sources\DeclarationExpressions
[05/06/2014 22:20:45 > e5e3ee: ERR ] From https://git01.codeplex.com/roslyn
[05/06/2014 22:20:45 > e5e3ee: ERR ] * branch DeclarationExpressions -> FETCH_HEAD
[05/06/2014 22:20:45 > e5e3ee: INFO] Already up-to-date.
[05/06/2014 22:20:45 > e5e3ee: INFO] [ERROR] Window title cannot be longer than 1023 characters.
[05/06/2014 22:20:45 > e5e3ee: INFO] Returning exit code 1
[05/06/2014 22:20:45 > e5e3ee: SYS INFO] Status changed to Failed
[05/06/2014 22:20:45 > e5e3ee: SYS ERR ] Job failed due to exit code 1
我在本地运行时从未收到此错误。
可能是什么原因?
答案 0 :(得分:0)
也许你正在运行的exe会改变Window Title。
因此,不要直接在您的PowerShell脚本中调用git
,而是使用cmdlet Start-Process