I am using below script to connect to remote server and shut the cluster service and then deploy packages. This is cluster service shut down script.
$SvcName = '${bamboo.ServiceName}'
$SvrNames = '${bamboo.deploy.hostname}'
#$SvcName = "'" + $SvcName + "'"
$SvrName = $SvrNames[0]
try {
$services = Get-WmiObject -Computer $SvrName -Authentication PacketPrivacy -Namespace 'root\mscluster' MSCluster_Resource |
Where {$_.Type -eq "Generic Service"} |
Where {$_.name -eq $SvcName}
if (-Not $Services) {
$SvcName + " is not installed on this computer."
} else {
Switch($services.state) {
'2' {
Write-Host "Cluster service $SvcName is online"
$SvcName = "'" + $SvcName + "'"
$cmd = "CLUSTER RES" + ' ' + $SvcName + ' ' + "/OFF"
$cmd1 = [scriptblock]::Create($cmd)
Invoke-Command -ComputerName $SvrName -ScriptBlock $cmd1
Start-Sleep -s 10
Write-Host "$SvcName is Offline"
}
'3' {
Write-Host "Cluster service $SvcName is Offline"
Write-Host $_.Exception
Write-Host $_.Exception.Message
Start-Sleep -s 10
break
}
'4'{
Write-Host "Cluster service $SvcName is in Falied state, Please login to $SvrNames and check event logs"
Start-Sleep -s 10
}
}
}
} catch {
$error[0].Exception
Write-Host $_.Exception
Write-Host $_.Exception.Message
break
}
Why does Bamboo does not fail when there is a clear exception or an error message in the deploy logs?
Do I need to do something different here?
$LASTEXITCODE
doesn't work as well.