Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to add bamboo build log lines into bamboo notification template?

I am currently getting bamboo notification emails, but it doesn't have any log lines included in it, I wanted to include last 100 lines of bamboo logs into notification email once bamboo plan is completed.

I was going through this documentation to customize bamboo notification templates but I couldn't find how to fetch log lines into my freemarker template. Please help me with this, I'm new to both freemarker & bamboo.

2 answers

Looks like I can't delete answer, so editing it!

0 votes

Hello @Abhishek S, Welcome to Atlassian Community!

Depending on the type of notification, some may not include any build logs as they don't have that information. Here's an example showing a logging macro:

[#-- ============================================================================================== @nc.showLogText --]
[#macro showLogs lastLogs baseUrl buildKey ]
[#if lastLogs?has_content]

Last Logs

[#list lastLogs as log]
${log.formattedDate} |  ${log.unstyledLog}

That is included on the common notificationCommonsText.ftl template. You may need to include that file on your custom one like this:

[#include "notificationCommonsText.ftl" ]


Eduardo Alvarenga
Atlassian Support APAC 

Thank you @Eduardo Alvarenga ! 

In my custom new file, once I include macro as,

<@showLogs lastLogs=? baseUrl=? buildKey=?>


what will be the values of the above variables (marked as question mark)?

I don't know how to fetch values (what are the keywords for to get logs etc.) for these variables. Can you please help me? 

An example would be highly helpful..

Hello @Abhishek S,

If you are including notificationCommonsText.ftl, lastLogs, baseUrl and buildKey will be already declared correctly. So you don't have to assign a value to them.

Check BuildHungHtmlEmail.ftl for good examples of how to print the logs.

You can also find more info here:


Kind regards,


Eduardo Alvarenga
Atlassian Support APAC 

Thank you @Eduardo Alvarenga !


I created a custom template called printLogs.ftl, under bamboo-home/templates/notification-templates.

The file has following content:

> cat printLogs.ftl 

[#include "notificationCommonsText.ftl" ]

[@showLogs lastLogs baseUrl buildKey /]


But still I'm not getting logs in the notification email. Can you please help me with this?

I've also restarted bamboo using sh

Hello @Abhishek S

The lastLogs variable is defined by the com.atlassian.bamboo.notification.buildhung.BuildHungNotification class in the lastLogs object context and will only work in case of hung builds notifications.

If you want to implement such logging on different notifications, you can place a direct http link to the Build logs instead.

Hello @Eduardo Alvarenga , Thank you !

Placing http link looks a good idea, but my requirement is to display logs in the notification email, so I tried using iframe in the template as follows,

<iframe src="{bamboo-logs-url}" style= "">



But again no logs were displayed, By any chance is there a way to bring logs when build fails? 

Hello @Eduardo Alvarenga 

Can you please have a look at my above reply?

Hello @Eduardo Alvarenga 

As it seems to have no solution to my problem using existing templates, I'm thinking to create my own notification plugin. Can you please help me how to create a plugin wrt my problem? Maybe some similar plugin as example would help a lot.


Hoping for your response, Thank you!

Abhishek S

Hi @Abhishek S

You can find more information on plugin development here:

Hi @Eduardo Alvarenga 

As soon as build completes it will trigger java files (ex: etc), which in turn sends notifications. Am I right? If I'm wrong can you please tell me what all happens in background as we get an email notification?

Is it possible to trigger some other java files/bash script as soon as build completes?


A reply would be highly helpful.

Hello @Abhishek S

Bamboo will call the equivalent notification class depending on the action that has invoked it. For BuildHungNotification, Bamboo will invoke it in case the Hanging build event is triggered.

Currently, the lastLogs object context is only available on the BuildHungNotification class.

There's an existing feature request to enable better log inclusion into notification templates

There are other requests for some extra functionality too:

Make sure to add yourself as a watcher to those tickets so you can get notified once the features are implemented.

Alternatively, you can add a new (final) Stage to your build plan that would contain a script task within a job that would fetch the build logs and build state (success/failure) from the past Jobs in that Plan using the Bamboo REST API and send their logs to your email recipients. Make sure to also exit that final Job within that Stage with the same return code provided by the last Job so it can match success/failure.



Eduardo Alvarenga
Atlassian Support APAC

Hi @Eduardo Alvarenga , thanks for the reply!

Bamboo will call the equivalent notification class depending on action that has invoked it.

Where are these classes located in the installation directory?

 Alternatively, you can add a new (final) Stage to your build plan that would contain a script task within a job that would fetch the build logs.

This is an option to consider, but can you please tell me how to fetch build logs inside task? (if through api please share it..)

@Abhishek S

The classes are compiled and cannot be easily read in the Bamboo installation directory. You can explore the Bamboo source code via (need a proper licence)

For reference, the classes are the ones listed here:

To fetch build logs you can use cURL GET/POST requests, more details here:



Eduardo Alvarenga
Atlassian Support APAC

Suggest an answer

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

Bamboo Data Center on Kubernetes

Hi, If you are running self-managed environments and looking to adopt modern infrastructure, Bamboo Data Center can now be deployed in a Kubernetes cluster. By leveraging Kubernetes, you can easily...

957 views 3 8
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