Inline script task Powershell/ batch in bamboo deployment project does not fail the deployment project when errored out or during any exceptions -


i using below script connect remote server , shut cluster service , deploy packages. 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 |     {$_.type -eq "generic service"} |     {$_.name -eq $svcname}   if (-not $services) {     $svcname + " not installed on computer."   } else {     switch($services.state) {       '2' {         write-host "cluster service $svcname 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 offline"       }       '3' {         write-host "cluster service $svcname offline"         write-host $_.exception         write-host $_.exception.message         start-sleep -s 10         break        }       '4'{         write-host "cluster service $svcname in falied state, please login $svrnames , check event logs"         start-sleep -s 10       }     }   } } catch {   $error[0].exception   write-host $_.exception   write-host $_.exception.message   break } 

why bamboo not fail when there clear exception or error message in deploy logs?

do need different here? $lastexitcode doesn't work well.

i've found work around.

most of errors in powershell throws exceptions. , unknown reason, bamboo doesn't seem take account when executing inline scripts.

we can fix doing our own exception catching inline, like:

try  {     call here fancy powershell functions } catch {     write-host $_.exception.gettype().fullname, $_.exception.message     exit 500     # or whatever code not 0 } 

with that, able have deployment failed. inline check $error[0] stated above works maybe not exceptions.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -