fixed error handling
This commit is contained in:
parent
c3fd873495
commit
f05a4240f2
3 changed files with 10 additions and 16 deletions
|
@ -16,6 +16,8 @@ set JENKINS_SERVER=jenkins.local
|
|||
|
||||
set AGENT_ROOT=C:\ws
|
||||
set WORKSPACE=%AGENT_ROOT%\workspace
|
||||
if not exist "%$WORKSPACE%" mkdir "%$WORKSPACE%"
|
||||
if not exist "%WORKSPACE%" mkdir "%WORKSPACE%"
|
||||
|
||||
net use E: \\results.local\exports
|
||||
|
||||
java -jar %SWARM_PLUGIN_JAR% -master http://%JENKINS_SERVER%:8080 -executors 1 -fsroot %AGENT_ROOT% -labels windows
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
# stop script on errors
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
$PSDefaultParameterValues['*:ErrorAction']='Stop'
|
||||
|
||||
|
||||
|
@ -41,9 +40,9 @@ function Invoke-CmdScript {
|
|||
function Invoke-Call {
|
||||
param (
|
||||
[scriptblock]$ScriptBlock,
|
||||
[string]$ErrorAction = $ErrorActionPreference
|
||||
[string]$ErrorAction = "Stop"
|
||||
)
|
||||
& @ScriptBlock 2>&1 3>&1 4>&1 | ForEach-Object { "$_" }
|
||||
& @ScriptBlock | ForEach-Object { "$_" }
|
||||
if (($lastexitcode -ne 0) -and $ErrorAction -eq "Stop") {
|
||||
Write-Error "Command $ScriptBlock exited with $lastexitcode."
|
||||
exit $lastexitcode
|
||||
|
|
|
@ -14,26 +14,19 @@
|
|||
|
||||
. ${PSScriptRoot}\common.ps1
|
||||
|
||||
#Set-PSDebug -Trace 1
|
||||
|
||||
# Wrap git commant in error handling function
|
||||
function Invoke-Git($cmd) {
|
||||
Invoke-Call -ScriptBlock { git @cmd } -ErrorAction Stop
|
||||
}
|
||||
|
||||
if (Test-Path -PathType Container "llvm-project"){
|
||||
Set-Location llvm-project
|
||||
Write-Output "performing git pull..."
|
||||
$branch = (git branch) | Out-String
|
||||
$branch = ($branch -split '\r')[0]
|
||||
if ($branch -ne "* master"){
|
||||
Invoke-Call -ScriptBlock { git checkout master} -ErrorAction Stop
|
||||
Invoke-Call -ScriptBlock { git checkout master}
|
||||
}
|
||||
Invoke-Call -ScriptBlock { git reset --hard } -ErrorAction Stop
|
||||
Invoke-Call -ScriptBlock { git clean -fdx } -ErrorAction Stop
|
||||
Invoke-Call -ScriptBlock { git pull } -ErrorAction Stop
|
||||
Invoke-Call -ScriptBlock { git reset --hard }
|
||||
Invoke-Call -ScriptBlock { git clean -fdx }
|
||||
Invoke-Call -ScriptBlock { git pull }
|
||||
# TODO: in case of errors: delete folder and clone
|
||||
} else {
|
||||
Write-Output "performing git clone..."
|
||||
Invoke-Call -ScriptBlock { git clone -q --depth 1 https://github.com/llvm/llvm-project } -ErrorAction Stop
|
||||
Invoke-Call -ScriptBlock { git clone -q --depth 1 https://github.com/llvm/llvm-project }
|
||||
}
|
Loading…
Reference in a new issue