It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get task configuration for a notification at the end of a stage

Thanks to Przemek I was able to find the task config data in the JobCompletedEvent.

However the listener for the JobCompletedEvent doesn't seem to be able to get the notificationRules (I get the net.sf.hibernate.LazyInitializationException: Exception initializing proxy - the owning Session was closed error message when calling NotificationManager#getNotificationRules()) even with Brydie's fix using a transactionTemplate wrapper for the call I get that exception.

Listening for a StageCompletedEvent however I have no trouble pulling out the notification rules for the plan, however I get an empty list of tasks in the config (presumably because tasks belong to parallel jobs, not stages).

So I need some way to access both notification rules and task config in one listener, I'm hoping for one of the following solutions :)

  1. There is another event I have not tried that can access the task config and rules
  2. There is a fix for one of the two problems above and one of these events should work
  3. By listening first for the JobCompletedEvent I can store the config I need into a data map that is accessible subsequently in the StageCompletedEvent listener. So with the two listeners, the second listener will have the information it needs to send off the notification.

Any suggestions would be really appreciated :)



2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted

Cracked it... Found the task config I was interested in from the stage completed event with the following:

for (StageExecution stage: stageCompletedEvent.getChainExecution().getStages()) {
         for ( BuildExecution build : chainStage.getBuilds()) {
            TaskDefinition task = build.getBuildContext().getBuildDefinition().getTaskDefinitions().get(0);
            requiredString = task.getConfiguration().get(REQUIRED_KEY);

Alternatively, can the StageCompletedEvent listener read the logs from the tasks? If so I could just log out the value I'm interested in from the task and parse it in the listener to send out the notification...

Community showcase
Asked in Atlassian Account

Upcoming AMA with the Atlassian Identity Product Managers!

"Atlassian Account" is a space where you can raise questions about your Atlassian Account and your identity across all of our Atlassian Cloud Products. This involves understanding User Managemen...

89 views 2 8
View question

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you