1

I am new to Atlasian Bamboo development and have a problem, if you could help me.

I develop a bamboo plugin and I have this xwork:

<xwork key="viewNFTResults" name="View NFT Results">
    <package name="nftResults" extends="buildResultView">
        <action name="viewNFTLogs" class="com.atlassian.sap.nftresults.impl.NFTLogsView">
            <result name="success" type="freemarker">/fragments/view-nft-results-log.ftl</result>
            <result name="error" type="freemarker">/fragments/error.ftl</result>
        </action>
    </package>
</xwork>
<web-item key="NFT:\${planKey}-\${buildNumber}" name="chainNFTResults" section="chainResults.subMenu/chainResults"
          weight="80">
    <label key="NFT logs"/>
    <link linkId="NFT:\${planKey}-\${buildNumber}">/build/result/viewNFTLogs.action?buildKey=${planKey}&amp;buildNumber=${buildNumber}</link>
</web-item>

In my ftl file I put in head:

<head>
    <meta name="decorator" content="result"/>
    <meta name="tab" content="chainNFTResults"/>
</head>

and the NFTLogsView class extends BuildResultsAction.

Now when I click the NFt logs tab when the build is running, the content of this tab is appears and the action performed and the page decorator is ok also, like that:

build running

But when I refresh the page or when the build is finished, and I am showing the tab (I mean inside the tab), I get this page:

build is finished

The other tabs disappeared and I git many exceptions in logs, like:

BambooActionSupport.getWebSectionsForLocation(String) threw an exception.

and...

`[INFO] [talledLocalContainer] ==> fn.hasPlanPermissionForKey("BUILD", 
stage.planKey)  [in template "lib/chains.ftl" at line 369, column 49]`

and...

BambooActionSupport.hasPlanPermission(String, String) threw an exception.

And many other exceptions. Although the action URL is the same when I click the tab and when refresh the page.

Any suggestions please.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99

1 Answers1

1

Finally, after a week of effort and help from the Atlassian Development team, we have found the cause and a workaround till this gets fixed in Bamboo.

JIRA: [https://jira.atlassian.com/browse/BAM-19884]

Cause: Following dependencies are not injected for Xwork action.

BambooPermissionManager, BambooAuthenticationContext, JiraApplinksService, WebInterfaceManager, VcsRepositoryConfigurationService, PlanExecutionManager, TriggerManager, PlanManager

Workaround

Add the following in the class that extends ViewBuildResult, spring scanner will find these dependencies and make them visible for plugin class loader when xwork action gets instantiated.

@ComponentImport
private BambooPermissionManager bambooPermissionManager;
@ComponentImport
private BambooAuthenticationContext bambooAuthenticationContext;
@ComponentImport
private JiraApplinksService jiraApplinksService;
@ComponentImport
private WebInterfaceManager webInterfaceManager;
@ComponentImport
private VcsRepositoryConfigurationService vcsRepositoryConfigurationService;
@ComponentImport
private PlanExecutionManager planExecutionManager;
@ComponentImport
private TriggerManager triggerManager;
@ComponentImport
private PlanManager planManager;

In pom.xml add the following (this might not be needed for the most recent version of spring scanner)

<Import-Package>
 org.springframework.osgi.*;resolution:="optional",
 org.eclipse.gemini.blueprint.*;resolution:="optional",
 com.atlassian.bamboo.applinks.*;resolution:="optional",
 com.atlassian.bamboo.build.*;resolution:="optional",
 com.atlassian.bamboo.plan.*;resolution:="optional",
 com.atlassian.bamboo.plan.trigger.*;resolution:="optional",
 com.atlassian.bamboo.security.*;resolution:="optional",
 com.atlassian.bamboo.user.*;resolution:="optional",
 com.atlassian.bamboo.vcs.configuration.service.*:="optional",
 com.atlassian.plugin.web.*;resolution:="optional",
 *
</Import-Package>

Link: Atlassian Forum

https://community.developer.atlassian.com/t/problem-with-decorator-in-xwork-the-page-is-displayed-without-tabs-and-lot-of-exceptions-in-the-log/18516/26

ktime
  • 63
  • 13