Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

What to do with AbstractCapabilityTypeModule methods?

EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2012

The dev article for developing new capability types found here https://developer.atlassian.com/display/BAMBOODEV/Capability+Type+Module

allows me to create and see my capability, but blows up when saving:

[INFO] [talledLocalContainer] 2012-05-05 11:01:13,885 ERROR [http-6990-1] [FiveOhOh] 500 Exception was thrown.
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.configuration.agent.ConfigureAgentCapability$2.addCapabilityAndSave(ConfigureAgentCapability.java:100)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.configuration.agent.ConfigureAgentCapability$2.visitLocal(ConfigureAgentCapability.java:83)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.v2.build.agent.LocalAgentDefinitionImpl.accept(LocalAgentDefinitionImpl.java:41)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.configuration.agent.ConfigureAgentCapability.doAddCapability(ConfigureAgentCapability.java:70)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

And thatis because the class specified in the plugin.xml must extend AbstractCapabilityTypeModule which includes the method getCapability(actionParams){..}

BUt I can't find in the API what that should return (other than null). I tried creating a new CapabilityImpl() and setting the key and value, but that only got me so far as :

public class GroupAgentCapability extends AbstractCapabilityTypeModule
		{
	private static final Logger log = LoggerFactory
			.getLogger(GroupAgentCapability.class);
	
	@Override
	public Capability getCapability(Map<String, String[]> params) {
		return new CapabilityImpl("group.agent.key", "any.value");
	}

	@Override
	public String getLabel(String key) {
		return "Group Agent Capability";
	}

	@Override
	public Map<String, String> validate(Map<String, String[]> params) {
		//no values to set, no errors!
		return new HashMap<String,String>();
	}


}

[INFO] [talledLocalContainer] 2012-05-05 11:00:16,211 ERROR [http-6990-6] [FiveOhOh] 500 Exception was thrown.
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.v2.build.agent.capability.CapabilitySetImpl.getCapability(CapabilitySetImpl.java:56)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.configuration.agent.ConfigureAgentCapability$2.addCapabilityAndSave(ConfigureAgentCapability.java:100)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.configuration.agent.ConfigureAgentCapability$2.visitLocal(ConfigureAgentCapability.java:83)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.v2.build.agent.LocalAgentDefinitionImpl.accept(LocalAgentDefinitionImpl.java:41)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.configuration.agent.ConfigureAgentCapability.doAddCapability(ConfigureAgentCapability.java:70)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

So obviously my Capability needs a CapabilitySet as well? Can someone point me to some design overview of how all these classes work together?

My desire is simple, a "flag" capability that marks certain agents to be picked up by my custom filter.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 17, 2012

Was able to get this working by examing some other capabilities (JDK).

It seems the trick is indeed to instantiate a new CapabilityImpl() but the keys used in the constructor must match up with the keys used in your i18n file, and other getters of the class.

See this source for the full class:

https://bitbucket.org/eddiewebb/bamboo-group-agent/src/822db5b0d86b/src/main/java/com/edwardawebb/bamboo/groupagent/capabilities/GroupAgentCapability.java

TAGS
AUG Leaders

Atlassian Community Events