diff --git a/scripts/git-build-deploy.ps1 b/scripts/git-build-deploy.ps1 index b79d469..9aa69d8 100644 --- a/scripts/git-build-deploy.ps1 +++ b/scripts/git-build-deploy.ps1 @@ -152,7 +152,23 @@ foreach ($entry in $replacements.GetEnumerator()) { $remoteScript = $remoteScript.Replace($entry.Key, $entry.Value) } -$remoteScript | ssh -o BatchMode=yes -o ConnectTimeout=10 $BuildServer 'bash -s' -if ($LASTEXITCODE -ne 0) { - throw "通知中心构建机发布失败,退出码: $LASTEXITCODE" +$localTemp = Join-Path ([System.IO.Path]::GetTempPath()) ("yyd-notification-deploy-{0}.sh" -f [guid]::NewGuid().ToString('N')) +$remoteTemp = "/tmp/$(Split-Path $localTemp -Leaf)" +try { + [System.IO.File]::WriteAllText( + $localTemp, + $remoteScript, + [System.Text.UTF8Encoding]::new($false) + ) + & scp -o BatchMode=yes -o ConnectTimeout=10 $localTemp "${BuildServer}:$remoteTemp" + if ($LASTEXITCODE -ne 0) { + throw "通知中心发布脚本上传失败,退出码: $LASTEXITCODE" + } + & ssh -o BatchMode=yes -o ConnectTimeout=10 $BuildServer "chmod 700 '$remoteTemp' && bash '$remoteTemp'; code=`$?; rm -f '$remoteTemp'; exit `$code" + if ($LASTEXITCODE -ne 0) { + throw "通知中心构建机发布失败,退出码: $LASTEXITCODE" + } +} +finally { + Remove-Item -LiteralPath $localTemp -Force -ErrorAction SilentlyContinue }