Trigger bamboo deploy plan creation in a plugin in 5.9
Asked by David Kesler:

We've written a plugin that triggers deployment plans programatically. After upgrading from 5.6 to 5.9 it has broken due to a backwards incompatible change in the bamboo api. Previously we used

```
Deploymentcontext context = deploymentExecutionService.prepareDeploymentContext(environment, version, reason);deploymentExecutionService.execute(context);
```

However in 5.9, deploymentExecutionService.execute now takes an environment and an EnvironmentTriggeringAction. I can't figure out how i'm supposed to create an EnvironmentTriggeringAction since it's an interface. i found EnvironmentTriggeringActionFactory, but that's also an interface. I tried wiring it in just like a service, but it doesn't get wired in. I can't find anything else that would let me create an EnvironmentTriggeringAction.

How am i supposed to trigger deploy plans now?

Also, tangentially, why was backwards compatibility broken without warning in the api changelog?


Answers:
author: Marcin Gardias
body: 1) The change had to be done because old logic was broken. There is no meaningful implementation for the old interface and it had to be removed. See: [](https://jira.atlassian.com/browse/BAM-15501 "Junk deploy builds stack up if the current deploy gets stuck")~~[BAM-15501](https://jira.atlassian.com/browse/BAM-15501 "Junk deploy builds stack up if the current deploy gets stuck")~~

2) Moreover, the correct method to be called when triggering deployment is NonBlockingPlanExecutionService.tryToStart(  
environment, environmentTriggeringAction). The method's signature:

```
 Future<ExecutionRequestResult> tryToStart(@NotNull Triggerable triggerable,                                              @NotNull BuildDetectionAction buildDetectionAction);
```

3) EnvironmentTriggeringAction is an interface because plugins triggering deployments are supposed to implement it. You can find examples in Bamboo source code.

4) If you want to use one of existing implementations of EnvironmentTriggeringAction, EnvironmentTriggeringActionFactory is available to plugins. In fact, deployment triggers built-in in Bamboo are implemented as plugins. They wouldn't work if the factory wasn't available to them.   
(did you put \<component-import\> statement into your atlassian-plugin.xml?)

comments: author: Marcin Gardias
body: Also, DeploymentExecutionService is now correctly annotated as @Internal.


author: Steffen Opel _Utoolity_
body: > How am i supposed to trigger deploy plans now?

Good question, I hope an Atlassian Bamboo team member chimes in here.
> Also, tangentially, why was backwards compatibility broken without warning in the api changelog?

Likewise a good question - we had stumbled over a significant (and as of today still undocumented) Bamboo 5.9 API change as well, and I have requested a resp. changelog update two month ago already, which you might want to watch/vote/comment on accordingly:

* <https://jira.atlassian.com/browse/BAM-16068>

While the minor sorting issue mentioned there too has meanwhile been (silently) fixed, the [Changes for 5.9](https://developer.atlassian.com/display/BAMBOODEV/Changes+for+5.9) documentation itself has not yet been amended in any way.

* I *really* appreciate that the actual issue that we had encountered has been addressed in due course (less than a day turn around for fixing a critical bug is excellent!) - regardless, I'm a bit at a loss what keeps the Bamboo team from documenting such changes properly (and ideally upfront/ongoing) so that the add-on ecosystem can keep concentrating on adding value to Bamboo (instead of chasing undocumented incompatibilities like the one at hand).