Trigger a Deployment from a Remote Agent in a Custom Plugin Task

Do to the nature of our rather complex (and required) deployment pipeline, we want to simplfy things by adding a manual Stage containing a custom plugin that will Trigger related Deployment Project deploys. 

 

To allow invocation on the Bamboo Server this can be implemented with a combination of DeploymentProjectService, EnvironmentTriggeringActionFactory, and NonBlockingPlanExecutionService. 

See:

https://github.com/vicsz/bamboo-trigger-deployment-task/blob/master/src/main/java/com/bambooplugin/impl/DeploymentTriggerTask.java

However the problem that I encounter is that is will not work on Remote Agent because of the more limited access available on it. 

See:

https://community.atlassian.com/t5/Answers-Developer-Questions/Bamboo-plugin-not-found-on-agents/qaq-p/478515

As expected when I check the Remote Agent Logs I see that the plugin failured to load due to missing dependencies. 

 is waiting for unsatisfied dependencies [[&applicationProperties, &deploymentProjectService, &nonBlockingPlanExecutionService, &environmentTriggeringActionFactory]]

The question is how to I solve this for remote agents ?? .. It seems like RuntimeTaskDataProvider is only meant for getting Server Side data,  how does one go about invoking something on the Server Side (from a Remote Agent) such as a deploy.

Thanks

1 answer

1 vote
Adam Slaski Atlassian Team Jul 18, 2017

I have two suggestions. You could have a look at the rest api, maybe the method https://docs.atlassian.com/bamboo/REST/6.1.0/#d2e774 could be of some use. You could also have a look at "After successful stage" trigger on your deployment project. 

If neither of my suggestions could solve your problem, please explain your use case so I can understand fully and provide more help.

Thanks Adam, 

I looked at both .. 

1) I don't think "After succesful stage" will work as we do release branching (i.e. release-49, release-50, etc) , but the Trigger forces you to select one branch.  I would want it to trigger for any branch (guarded by a manul step). 

 

2) Looked at REST API , and have spiked it out ... Certainly doable, albeit a bit hacky ... But it would require that my plugin now has Username / Password to connect over REST to the Server.    

 

I'm assuming there's no easy way to do this via pure Plugin ? 

Adam Slaski Atlassian Team Jul 18, 2017

it would require that my plugin now has Username / Password to connect over REST to the Server.

For sure, you can keep password in a global variable. Just make sure to include the string "password" in the variable name so that it would be masked. 

 

Thanks Adam,  

I think that's the solution that i'll be taking .. 

For future reference, is there a way to have a Build Task run actions on the Server (not via Rest).  Some kind of PostBuild Task, etc ? 

Adam Slaski Atlassian Team Jul 21, 2017

Hi Victor,
There is a plugin Pre-Post Build Command Runner (https://marketplace.atlassian.com/plugins/com.sysbliss.bamboo.plugins.prepost-build-command/server/overview) that can run a shell command on an agent or on a server.
This is not exactly what you asked for, but I hope you find it useful. In case you would like to extend that plugin, please find the source code repository here: https://bitbucket.org/atlassian/bamboo-prepostcommand-plugin .

Adding solution for anyone thats interested. 

We ended up just scripting the deploy using Gradle + Bamboo API Calls. 

We created a seperate Release Pipeline Plan , with different Manual Stages for different environments. 

Snippet is available at: 

https://gist.github.com/vicsz/b04c31f27a91b0d32b55b1bf718ab705

Suggest an answer

Log in or Sign up to answer
Community showcase
Published 8 hours ago in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

53 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you