Search code examples
bambooatlassian-plugin-sdk

How to use the Executable (defined as Capability in Bamboo) in the plugin code


From the sample code on Atlassian site

https://developer.atlassian.com/server/bamboo/executing-external-processes-using-processservice/

ExternalProcess process = ProcessService.createExternalProcess(taskContext, new ExternalProcessBuilder().*command*(Arrays.asList("**/bin/ls**")). workingDirectory(fileWorkingDir));

What Bamboo API should I use to fetch "/home/kshi/.local/bin/robot" and pass it to command(). Getting the values from TaskConfiguration configuration map, or TaskDefinition did not help.

I do have the below tag in my atlassian-plugin.xml

< executable key="**robot**" nameKey="RobotFrameworkTest.robotExecutable"/ >

RobotFrameworkTest.robotExecutable points to "robot"

enter image description here

I want to make use of the Executable defined in bamboo. (/home/kshi/.local/bin/root)

From the logs of the plan I can see that Bamboo is referring to the robot command as bamboo.capability.system.builder.command.robot, wondering if I have to use it in the same way in the code.


Solution

  • I have found a relevant link on Atlassian website hinting ways to use an executable.

    https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-access-build-variables-from-a-bamboo-task/qaq-p/572570

    @ComponentImport private final ProcessService processService;
    @ComponentImport private final CapabilityContext capabilityContext;
    
    public RobotTestTaskType(final ProcessService processService, final CapabilityContext capabilityContext)
    
    { this.processService = processService; this.capabilityContext = capabilityContext; }
    String robotExecutable = capabilityContext.getCapabilityValue("system.builder.command.robot");