Problem with decorator in xWork, the page is displayed without tabs and lot of exceptions in the log

bamboo
atlassian-connect-dev
atlassian-platform-devs
bamboo-server

#10

I don’t see any problems with ftl nor atlassian-plugin.xml, but I would use /build/result/viewRobotReport.action?buildKey=${buildKey} at web-item link declaration.

Something is broken at isode.robot.RobotReport class, because simple class like I’ve shared works without any issues at Bamboo 6.5


#11

I was reading on some atlassian post suggesting the planKey should be used instead of the buildKey. But I will try and see if it works. Could you share the sample code of the class that extends from ViewBuildResults ?
There is no guideline / sample implementation of such a class on the Plugin tutorials. I would be very helpful to have a sample implementation somewhere to have the basic stuff ready.

I think we are missing some initialization in the implementation of RobotReport class that extends ViewBuildresults.
I don’t mind sharing my implementation of the class if you want to take a look at it to find any problem it has just 50 lines. Let me know

I have already taken a look at the below :slight_smile:
https://bitbucket.org/atlassian/bamboo-build-times-plugin/src/031df1939e4d9122d90a40616d5ce664b45effc9/src/main/java/com/atlassian/bamboo/plugin/buildtimes/ViewBuildTimes.java?at=master&fileviewer=file-view-default


#12
public class NFTLogsView extends BuildResultsAction {
    private String HrefRobotLogPath;

    public String getHrefRobotLogPath() {
        return "https://google.com";
    }
}

Please share it. By default you don’t need any special initialisation for this class


#13

It’s PlanResultsAction which shows tab at Plan result level, not job level


#14

Below is my implementation
Some of the bigger function definitions are replaced with (…) here.
I am extending my class from ViewBuildResults as I need functions like getSharedArtifactPath()
for getting the path of the shared artifacts.

@Scanned
public class RobotReport extends ViewBuildResults {

    public RobotReport(@ComponentImport StorageLocationService storageLocationService){
    }   

    public String execute() throws Exception {
        String strBuildList = doExecute();
        return strBuildList;
    }   

    /** The framework would export ${RobotReportSharedArtifactPath} in the FreeMarker Template */
    public String getRobotReportSharedArtifactPath(){
        return getSharedArtifactPath()+"/Robot-Reports/report.html";
    }   

    /** The framework would export ${RobotLogSharedArtifactPath} in the FreeMarker Template */
    public String getRobotLogSharedArtifactPath(){
        return getSharedArtifactPath()+"/Robot-Reports/log.html";
    }   

    /** Returns: TPRO1-TPLAN1-JOB1 */
    public String getRobotPlanKey(){
        ...

    /** Returns: TPRO1-TPLAN1-JOB1-4 */
    public String getRobotPlanResultKey(){
        ...
    }   

    /** Returns: TPRO1-TPLAN1 extracted from TPRO1-TPLAN1-JOB1 */
    public String getPlanId(){
        ...
    }   

    public String getHrefRobotLogPath(){
        ...
    }

    public String getHrefRobotReportPath(){
       ...
    }

}

#15

Hello,
I got the same / a similar issue.

$ atlas-version
ATLAS Version: 6.3.10
ATLAS Home: /usr/share/atlassian-plugin-sdk-6.3.10
ATLAS Scripts: /usr/share/atlassian-plugin-sdk-6.3.10/bin
ATLAS Maven Home: /usr/share/atlassian-plugin-sdk-6.3.10/apache-maven-3.2.1
AMPS Version: 6.3.15

At https://bitbucket.org/MarkusSchulte/devhelp1230, I added a minimal Bamboo-plugin (close to my own one), which has the problem.

Start the project by checking it out, and using “atlas-run”. Create a plan, and run it.

I added tab/panel “A label”, which is added at the plan build result correctly. When I click on the tab, everything is fine. If use the link to the tab http://markus-aspire-vn7-592g:6990/bamboo/build/result/devhelppanel.action?planKey=SOM-SOM&buildNumber=1 directly, the markup is broken.


#16

buildKey reports the same problem.


#17

Don’t use doExecute method in RobotReport. As nearest doExecute method implementation is at com.atlassian.bamboo.ww2.BambooActionSupport
Use super.execute() from com.atlassian.bamboo.build.BuildResultsAction as it does some initialisation of buildResults etc


#18

After some debug I can confirm it’s a bug in Bamboo. Some dependencies of Action from plugin are not injected. It works when user clicks tab from UI, but doesn’t work if refresh page.
I’ll create public issue at https://jira.atlassian.com/browse/BAM when gather more details


#19

Use workaround while there’s no fix for this issue:
Add these code to any of your class, it might be better to create new one just for this purpose

@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;

The problem that when Bamboo initialise action from plugin it doesn’t scan for required dependencies so class loader doesn’t see classes which BambooActionSupport class requires to render page menu. Workaround above forces adding of missing dependencies to Spring configuration of plugin.

Workaround works if you use spring-scanner to generate dependencies


#20

Hi @achystoprudov,

Thanks for looking into this and sharing the work around.

Cheers,
Anne Calantog


#21

Hi Alexey,

Thank you for acknowledging the bug and suggesting the workaround. I will try to implement the workaround on my dev env now. Will let you know if it solves the problem.

Regards,
Kshi


#22

Hi Alexey,

The workaround did not work.
Using super.execute with / without the workaround gave further JAVA exceptions.

The problem still persist.

Not sure if I am doing the right thing as a part of work around.
Here is the relevant code…

@Scanned
public class RobotReport extends ViewBuildResults {

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

    public RobotReport(final StorageLocationService storageLocationService, final BambooPermissionManager bambooPermissionManager,
                           final BambooAuthenticationContext bambooAuthenticationContext, final JiraApplinksService jiraApplinksService,
                           final WebInterfaceManager webInterfaceManager, final VcsRepositoryConfigurationService vcsRepositoryConfigurationService,
                           final PlanExecutionManager planExecutionManager, final TriggerManager triggerManager, final PlanManager planManager){

        this.storageLocationService = storageLocationService;
        this.bambooPermissionManager = bambooPermissionManager;
        this.bambooAuthenticationContext = bambooAuthenticationContext;
        this.jiraApplinksService = jiraApplinksService;
        this.webInterfaceManager = webInterfaceManager;
        this.vcsRepositoryConfigurationService = vcsRepositoryConfigurationService;
        this.planExecutionManager = planExecutionManager;
        this.triggerManager = triggerManager;
        this.planManager = planManager;
    }   

    public String execute() throws Exception {
        String strBuildList = super.doExecute();
        return strBuildList;
    }

Do I need do make any change to the pom.xml ?
How do I verify that the dependencies are injected ?
Do I need to update the atlassian-spring-scanner version ? (<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>)


Plugin is not enabled while running on remote-agent because of unsatisfied dependencies
#23

@markusschulte Did the work-around provided worked for you ?


#24

@achystoprudov @kshi.korde

The workaround does not work in my case, too. I think it cannot work, because (at least) field BambooActionSupport.authenticationContext is private.

I did some research myself, and updated my bug-demo at BitBucket with a working workaround, you can see the changes/fix/workaround at https://bitbucket.org/MarkusSchulte/devhelp1230/branches/compare/fix…#diff. In my usecase, using this addon is now without any exception being thrown.
Note this project “devhelp1230” was created using latest atlas-create-bamboo-plugin, and is because of this an Atlassian Spring scanner v1.2 addon. I think the workaround will be less freaky, when using Atlassian Spring scanner v2.


#25

You don’t need to set these fields via constructor. You need to let spring-scanner find these dependencies and make them visible for plugin class loader when instantiate action. As I said you can have separate class with only code I’ve submitted


#26

@achystoprudov @markusschulte looks like it is working. I will just play around with it by creating a few more jobs and plans and confirm that nothing breaks now. :slight_smile:

@markusschulte I did not add “setAuthenticationContext” (the one in your source) and it still worked for me (with the workaround suggested by Alexey).
I just additionally added com.atlassian.bamboo.vcs.configuration.service.*:="optional" in my pom.xml which was missing in your pom.xml.

@acalantog and @achystoprudov @markusschulte thanks a ton !!!


#27

Created an issue to track progress: https://jira.atlassian.com/browse/BAM-19884


#28

@achystoprudov , @markusschulte

I have another question, it is regarding the same context so asking it here.

In my atlassian-plugin.xml (above) my web-item has a link which is associated with the action viewRobotReport

"/build/result/viewRobotReport.action?planKey=${planKey}&buildNumber=${buildNumber}"

When I switch to a job for which the RobotReportViewCondition evaluates to false, I can still set the html report rendered by my freemarker template /templates/viewRobotReport.ftl

From the logs I could see that the link action called is instantiated first (which returns success) and then the condition class (RobotReportViewCondition) is instantiated which returns false. So I end up in a job which does not show the web-item in the tab but shows the report rendered by the freemarker template.

From what I understand, this is because the web-item link action gets executed first and then the web-item display condition gets evaluated later.

This behavior I find strange.

How can I correct this ?


#29

Got around this. Implemented the same condition that I implemented in RobotReportViewCondition