I am trying to develop an application which will create n number of plans. The REST API provided by bamboo does not have API's to create plans. So I am thinking of creating a Bamboo REST Plugin myself and develop API's to create Plan.
I am using Latest version of Atlassian SDK. I am able to create sample REST API's. But I am not able to create Plan using REST API. I am using PlanManager class to create Plan. But the planManager.createPlan(plan) method throws error
java.lang.IllegalArgumentException: Don't know how to handle permissions for com.....external.impl.MyPluginComponentImpl$1@921f7314
I am extending the class com.atlassian.bamboo.plan.AbstractPlan to create a concrete class for Plan interface.
Please help me.
Community moderators have prevented the ability to post new answers.
Hello @Dhepu Nettady UST,
Try to create plan with provided code
final BuildConfiguration buildConfiguration = new BuildConfiguration(); final Map<String, Object> context = new HashMap<>(); context.put(PlanCreationService.EXISTING_PROJECT_KEY, "PROJ"); context.put(ChainCreationService.CHAIN_KEY, "TEST"); String key = chainCreationService.createPlan(buildConfiguration, new ActionParametersMapImpl(context), PlanCreationService.EnablePlan.ENABLED); PlanKey planKey = PlanKeys.getPlanKey(key); //it's required to refresh caches and notify listeners chainCreationService.triggerCreationCompleteEvents(planKey);
And then add stages and jobs with com.atlassian.bamboo.plan.stage.StageService.addStage() and com.atlassian.bamboo.plan.job.JobService.addJob()
I pasted your code in to my createPlan REST API implementation.
When I invoked the REST API I am getting PlanCreationException
[INFO] [talledLocalContainer] com.atlassian.bamboo.build.PlanCreationException: Failed to create new plan. No user was found in the context [INFO] [talledLocalContainer] at com.atlassian.bamboo.build.creation.PlanCreationTemplate.validateThrowingPlanCreationException(PlanCreationTemplate.java:570) [INFO] [talledLocalContainer] at com.atlassian.bamboo.build.creation.ChainCreationServiceImpl.getDefaultPermissionsForPlan(ChainCreationServiceImpl.java:245) [INFO] [talledLocalContainer] at com.atlassian.bamboo.build.creation.PlanCreationTemplate.createPlan(PlanCreationTemplate.java:244) [INFO] [talledLocalContainer] at com.atlassian.bamboo.build.creation.ChainCreationServiceImpl.createPlanAndKey(ChainCreationServiceImpl.java:574) [INFO] [talledLocalContainer] at com.atlassian.bamboo.build.creation.ChainCreationServiceImpl.createPlan(ChainCreationServiceImpl.java:543)
How can I add a user to the context?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks,
I am able to create Plan.
In had to add Basic Authentication to the REST request.
And also I had to add the below code also. Other wise IllegalArgumentException is coming.
buildConfiguration.addProperty(Repository.SELECTED_REPOSITORY, NullRepository.KEY);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have a question here.The Repository.SELECTED_REPOSITORY is deprecated as per javadoc. "Deprecated. since 3.3 repository definition is no longer part of BuildConfiguration"
Is there any other way other than this deprecated constant?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.