Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Matt Curtis April 23, 2013

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 :)

Thanks,

Matt

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
Matt Curtis April 24, 2013

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);
         }
      }

0 votes
Matt Curtis April 23, 2013

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...

TAGS
AUG Leaders

Atlassian Community Events