• Community
  • Products
  • Bamboo
  • Questions
  • Inline script task with powershell commands does not fail the bamboo deployment project when errored out or during any exceptions

Inline script task with powershell commands does not fail the bamboo deployment project when errored out or during any exceptions

Hi 

 

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+' '+"/ON"
$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

 

1 answer

This widget could not be displayed.

Bamboo has no idea if the errors in the log are important or not.  If your script fail it should return non-zero exit code to indicate that.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

124 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you