How to replace notifications in deployment project environments with Bamboo's Java API?


I want to programatically replace existing notifications in deployment project environments with Bamboo’s Java API. Unfortunately, there is no setNotificationSet(NotificationSet) method in com.atlassian.bamboo.deployments.environments.Environment as there is in com.atlassian.bamboo.chains.Chain.

When I - instead of replacing notifications - try to first delete the existing and then add the new ones like follows

for (NotificationRule rule: environmentService.getNotificationSet( {
  environmentService.deleteNotification(, rule);

for (NotificationRule rule: newNotificationRules) {
  environmentService.addNotification(, rule);

I always get the following error:

org.springframework.orm.hibernate5.HibernateJdbcException: JDBC exception on Hibernate data access: SQLException for SQL [insert into NOTIFICATIONS (RECIPIENT_TYPE, RECIPIENT, NOTIFICATION_SET, CONDITION_KEY, CONDITION_DATA, NOTIFICATION_RULE_ID) values (?, ?, ?, ?, ?, ?)]; SQL state [null]; error code [0]; could not execute batch; nested exception is org.hibernate.exception.GenericJDBCException: could not execute batch
 at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(
 at org.springframework.orm.hibernate5.HibernateTransactionManager.convertHibernateAccessException(

Any ideas what I’m doing wrong?


1 Like