修复构建机发布脚本传输
This commit is contained in:
parent
97e380b138
commit
131a9f4c4c
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user