How to setup notifications for a Bamboo Deployment plan that hangs up?
Asked by sasoRP:

Similar to what happens on the Bamboo Plans, I'd like that my deployment plans to notify me by email every time a deployment hangs up.

Is that possible?

Thanks.

Pedro Rosas


Answers:
author: Gerhard Forster
body: Hello Pedro. Thanks for your inquiry.

When mentioning build plan notifications, you likely speak about the build notification "Job hung". Please find this, along with all other build notification options sketched in the following KB:

[https://confluence.atlassian.com/bamboo/configuring-notifications-for-a-plan-and-its-jobs-289276973.html](https://confluence.atlassian.com/bamboo/configuring-notifications-for-a-plan-and-its-jobs-289276973.html "Configuring notifications for a plan and its jobs")

With regards to deployment notifications, this is the related KB:

[https://confluence.atlassian.com/bamboo/notifications-for-deployment-environments-342754193.html](https://confluence.atlassian.com/bamboo/notifications-for-deployment-environments-342754193.html "Notifications for deployment environments")

Deployment notifications are not configured on deployment project level, but inside each deployment environment of a deployment project. So to add a deployment notification, you need to open a deployment environment per "Edit environment" (pencil symbol on the right) on the "Deployment projects" page and there press button "Notifications" and then "Add notification".

The selectable notification events are "Deployment started and finished", "Deployment finished" (according to the above KB) and also "Deployment failed" which is missing out in the document from above (our sincere apologies for that).

Now failing is not hanging, but if a deployment is kicked off and never finishes, it kind of fails. So in order to receive the hanging information, I see basiaclly two options for you:

1. You notify the wished recipient per the opposite, namely "Deplyment finished". That means, whenever a deployment was triggered but hangs, this notification is NOT received. So it's the reverse logic of what you wanted to have, but e.g. some Bamboo-external scripting might turn it into what you aim to receive.
2. You'd need to identify if the deployment is hanging (for which I will point you to a Bamboo REST endpoint that will show you if a deployment is queued and waiting. So queries on that for a defined and long enough time e.g. per Bamboo Script task within your deployment, without any status change, should indicate hanging) and if so, make the deplyment fail e.g. per exit(1) from the same or another Bamboo Script task. If your deployment notification event was set to "Deployment failed", this would now effectively call out this deployment as hanging.

Please find details of Bamboo's RESTful API in our Bamboo REST API Tutorial [https://docs.atlassian.com/atlassian-bamboo/REST/6.8.1/](https://docs.atlassian.com/atlassian-bamboo/REST/6.8.1/ "Bamboo REST API Tutorial") and the endpoint that I mentioned above below. It uses the GET method, of course.

```
/queue/deployment?expand
```

Are either option 1 or 2 from above applicable for you? We hope so.

Please let us know if there is more that we can assist you on here.

Thanks and cheers,  
Gerhard