Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bamboo ProcessService bean does not exist?

Tags:

Following https://developer.atlassian.com/bamboodev/bamboo-tasks-api/executing-external-processes-using-processservice I would like to invoke some command using ProcessService bean. The injection as described in the link, does not work. I checked the source of several other plugins at Bitbucket, but each is using the concept as described in the link.

My class:

import com.atlassian.bamboo.process.ProcessService;

public class CheckTask implements TaskType {
    private final ProcessService processService;
    public CheckTask(@NotNull final ProcessService processService) {
        this.processService = processService;
    }

However Bamboo does not find the ProcessService bean and fail with following:

(org.springframework.beans.factory.UnsatisfiedDependencyException : Error creating bean with name 'bamboo.tasks.CheckTask': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.bamboo.process.ProcessService]: : No qualifying bean of type [com.atlassian.bamboo.process.ProcessService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.bamboo.process.ProcessService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {})

Am I missing something ? Bamboo version: 5.13.0 AMPS version: 6.2.6

like image 344
Kousalik Avatar asked Aug 16 '16 07:08

Kousalik


2 Answers

The solution in the end was quite simple, no oficial docs discuss the solution though. Hope this helps you a bit.

Finally thanks to this post I made it work: https://answers.atlassian.com/questions/33141765/testcollationservice-not-injected-into-tasktype-constructor-on-sdk-bamboo

import com.atlassian.bamboo.process.ProcessService;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;

@Scanned
public class CheckTask implements TaskType {

    @ComponentImport
    private final ProcessService processService;

    public CheckTask(@NotNull final ProcessService processService) {
        this.processService = processService;
    }

The rest of the project was basicaly default, as generated by atlas-create-bamboo-plugin.

like image 166
Kousalik Avatar answered Oct 15 '22 18:10

Kousalik


Try to add in your atlassian-plugin.xml next line

<component-import key="processService" 
        interface="com.atlassian.bamboo.process.ProcessService"/>

That should help you

like image 42
Solorad Avatar answered Oct 15 '22 19:10

Solorad