How to render my freemarker template from java?


please I am new to Bamboo development and have some question, if you could hellp me.

I have this xWork:

<xwork key="viewNFTResults" name="View NFT Results">
<package name="nftResults" extends="buildResultView">
<action name="viewNFTResults" class="">
<result name="success" type="freemarker">/fragments/view-nft-results-log.ftl</result>

<web-item key="NFT:\${planKey}-\${buildNumber}" name="chainNFTResults" section="chainResults.subMenu/chainResults"
<label key="NFT Results"/>
<link linkId="NFT:\${planKey}-\${buildNumber}">/browse/nft_results/viewNFTResults.action?buildKey=${planKey}&amp;buildNumber=${buildNumber}</link>


First Question: please any exapmles what I can use instead of  extends="buildResultView", which choises?

Second Question: any examples about the action element? how the result element works?

Third Question: in the MyPostJobAction I implement PostJobAction and I override the excute method, because I need to get some data after every job is finished, here I want to render the view-nft-results-log.ftl file with new context, I do like that:

public class MyPostJobAction extends PlanResultsAction implements PostJobAction {

public void execute(@NotNull StageExecution stageExecution, @NotNull Job job,
@NotNull BuildResultsSummary buildResultsSummary) {

// for example i have here a map that I will fill with my own data
Map<String, Object> objectMap = new HashMap<String, Object>();

objectMap.put("NFTResults", Job);

//from here please how I can provide my ftl file with this map as a new context
and how to render the ftl file also from here after that?
thank you very much in advance. 


1 answer

1 vote

1. Don't extend PostJobActions, it's not meant for UI at all. It's an action that executes as part of the build process. If you need such thing at all, it should be a separate class.

2. Your action class should be sth like

public class MyAction extends BuildResultsAction {

public String execute() {
BuildResultSummary bs = getBuildResultsSummary();
//do stuff with the result
return SUCCESS; //this is ftl result

You DON'T render ftl template. Framework does it for you. If you want to use data from the action in the template you expose it by declaring a public method in the action class for instance, if you want to have this in the ftl:


 you do the following in the action:

public String getMyData() {
return "blah blah blah";

You can use other types than String of course. NFTResults

3. Action return element tells the framework what to do after your action depending on what your action returns. Your execute method returns a string. The string is the matched against defined return elements and matching action is executed. The action can be  for instance rendering an ftl template or redirecting to another action.

Hi Marcin,

Thank you, your answer solved one problem but I still have another one, if you can help me please.

I implemented PostJobAction here becasue I need to perform a functionaltily when the every job is finished and provide the result once agian to the ftl file to show it inside the tab.

That is why I asked about render ftl template from java code.

So, I need to render the ftl template UI after evrey job is finished.


Thank you very much in advance. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Opsgenie

Getting the Most out of Atlassian and Opsgenie Together

We’re excited to invite you to this action-packed webinar where we will demonstrate how to integrate Opsgenie’s powerful alerting and on-call management tools with your entire Atlassian stack. Mar...

65 views 0 0
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you