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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 access build variables from a bamboo Notification Edited


I'm trying to develop a new Bamboo Notification Plugin.

According to the official documentation - if I want to create my special Notification, in which I want to add a log file as attachment to my email, for example, I need to implement the following interface ExtendedNotification.  

This interface has a method that need to be implemented. The problem is getting the build version from the context in this method to try to attach the correct log file (for example - \BAMBOO\tools\logs\${bamboo.planKey}\health_${bamboo.buildNumber}.txt). 

My code is below : 

public Email updateEmail (@NotNull Email email) {
try {

//VariableContext variables = taskContext.getBuildContext ().getVariableContext ();

// E:\Atlassian\BAMBOO\tools\logs\${bamboo.planKey}\health_${bamboo.buildNumber}.txt
File logFile = new File ("E:\\Atlassian\\BAMBOO\\tools\\logs\\" + taskContext.getBuildContext().getPlanKey () + "\\health_" + taskContext.getBuildContext().getBuildNumber() + ".txt");

//Message message = new MimeMessage(session);
Multipart multipart = new MimeMultipart ();

// creates body part for the message
MimeBodyPart messageBodyPart = new MimeBodyPart ();
messageBodyPart.setContent (getHtmlEmailContent (), "text/html");

// creates body part for the attachment
MimeBodyPart attachPart = new MimeBodyPart ();

// code to add attachment...will be revealed later
attachPart.attachFile (logFile);

// adds parts to the multipart
multipart.addBodyPart (messageBodyPart);
multipart.addBodyPart (attachPart);

// sets the multipart as message's content
email.setMultipart (multipart);
} catch (Exception e) {
log.error ("There was a problem composing the email", e);
return null;
return email;

I tried to follow the guidelines provided here :,


but there is no way of getting the taskContext. 

Any ideas ?

Thanks !

1 answer

As I posted this question in stackoverflow, this is the answer : 

Finally, I found the way to make it work.

Those variable I want to get, the planKey and the buildNumber are coming from the following :

public class MyNotification extends AbstractCompletedNotification implements ExtendedNotification {
    private ResultsSummary resultsSummary;
    private ImmutablePlan plan;

    public Email updateEmail (@NotNull Email email) {
        try {

            File logFile = new File ("E:\\Atlassian\\BAMBOO\\tools\\logs\\" + 
                plan.getPlanKey () + 
                "\\health_" + 
                resultsSummary.getBuildNumber() + 

And the plan and the resultSummary are set in the MyNotificationEventListener when I create my custom notification - MyNotification :

public class MyNotificationEventListener {
    public void handleEvent (@NotNull Object event) {
        if (event instanceof ChainCompletedEvent) { // for example
            MyNotification myNotification = (MyNotification) BambooNotificationUtils.createNotification (MyNotification.class);
            myNotification.setResultsSummary (this.resultsSummaryManager.getResultsSummary (chainCompletedEvent.getPlanResultKey ()));
            ImmutablePlan immutablePlan = this.planManager.getPlanByKey (chainCompletedEvent.getPlanKey ());
            myNotification.setPlan (immutablePlan);

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

703 views 1 6
Read article

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