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

How to inject a variable or custom data that can be used by a Deployment Project for Versioning.

Casey Entzi August 11, 2013

Pre-Context: Currently the build scripts that bamboo runs, determines the version number which is external to Bamboo. I would like a version to be created and deployed when a build successfully runs under a certain plan. I need someway to communicate the version to the Bamboo deployment project. Currently, it appears that this is only works through plan variables or build variables.

I've tried this a couple ways already, I've tried the bamboo inject variables pluging, which only currently lets you do job varaibes and doesn't work in this scenario. I've downloaded the source to the code (which looks like it's supposed to support plan variables) and it also doesn't work. I've also tried using VariableDefinitionManager.saveVariableDefinition, but it appears to save the plan variable so that it can be used on consecutive builds, but doesn't update the current build (there is a defect or feature request written up on this).

Is there another plugin type I can implement or a way I can pass the version number to the Bamboo Deployment Project?

7 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Felipe Kraemer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 1, 2014

Hello Casey,

I've discussed this issue with our development team, and we've realized that this is a feature that we don't have in Bamboo at the moment.

I have created a new issue in our development issue tracker for this functionality to ensure our development team is aware of your request:

https://jira.atlassian.com/browse/BAM-14441

I would suggest adding any comments to the issue above as well as voting on the issue to create it's popularity and likelihood of being implemented in a future release.

For more information on how Atlassian implements new features and improvements please see the following document:

http://confluence.atlassian.com/display/DEV/Implementation+of+New+Features+Policy

My apologies that I don't have a solution for you at this time.

Kind regards,
Felipe Kraemer
Atlassian Support

1 vote
Dan Carter November 7, 2013

I'm having a similar issue. I want to be able to pass the variable created by the inject variable plugin to the versioning system for a deployment project, but cant find a way to do it. I did managed to get the version number into the deployment job though..

I created a shared artifact which was is the text file that inject variables pulls in. I then shared this artifact so the deploy job could download it, and then ran the inject variables job again on the deploy task to get the variable in.

The text file gets changed on a per build basis using an ssh script (the script runs echo -e "current_version=`git describe`" > current_version.txt)

Sadly, the release version number thing eludes me still though!

0 votes
Casey Entzi April 23, 2014

Finally figured out a work around to this... If you deploy your releases to environments in a specified order.. dev, qa, etc...

You can add a console utility that updates the bamboo database with the proper version name as step in the dev deployment.

Our commandline utility takes in the Deployment Project Name (${bamboo.deploy.project}), Current Version Name (${bamboo.deploy.version}, this will be the wrong auto generated version), and the New Version Name.

It then queries the deployment_project table of the bamboo database with the project name passed in, what you need is the long id from the deployment_project table.

Then you need to query the deployment_version table with the id and the current version name (the wrong auto generated one). Then update the entry in the deployment_version table with the correct version name.

When you refresh your page, the name is correct. We were able to turn auto deployment on, and everything works flawlessly.

This also has the added benefit of stomping on and making sure the version is in fact correct programmatically and not allowing someone to make it an invalid name.

Xabier Davila August 26, 2014

I find unbelievable that we have to hack in the DB in order to be able to properly use versioning. Even more frustrating considering releasing from JIRA won't propagate the version name to release/deployment projects

0 votes
Casey Entzi March 6, 2014

Yeah, this is the same thing I ran into before, the code in Maven Pom Plugin will change the Plan Variable, but it doesn't change the variable in the context of the current build, so if the build changes the version from 1.0.0.15 to 1.0.0.20, when you go to deploy it, it will still try to version it 1.0.0.15. It won't try to version it 1.0.0.20 till the next build. So it will always be a build behind what the version should be. I pulled the code out of here:

https://bitbucket.org/dehringer/bamboo-maven-pom-extractor-plugin

assuming that was the plugin you were talking about. I just wired that up to the Inject Variables plugin, which as I stated does indeed change the plan variable, but only does it in context of the next build that will run, not the current one.

If you have a specific scenario of being able to change a plan variable in the context of a build that is currently running, let me know. That would be awesome!.

0 votes
Casey March 6, 2014

Hm... I'll have to go back and check the source for the Maven Pom Plugin and maybe I can port what it's doing to the Inject Variables Plugin. So you've gotten it to actually automatically set the deployment release? I tried everything to get that to work modifying the Inject Variables Plugin Source Code, I wonder if they changed anything in some of the latest releases to make this possible. Or I was doing it wrong. But if Maven Pom works then I can compare that source code and get the Inject Variables Plugin to work with Plan variables.

0 votes
Guillaume Dupéré March 6, 2014

I have been able to do so using the Maven Pom plugin and bamboo 5.3+.

If you are using maven, it is a plus since the pom extractor gets the version variable and includes it as part of the plan variable and is therefore usable by the deployment project.

Have a try !

If you don't use maven, nothing prevents you from creating a dummy pom file (xml) and update that version using any xml reader/writer (libxml on linux or perl is good enough).

If you need more info , please let me know !

0 votes
Guillaume Dupéré August 27, 2013
Can someone from atlassian answer the question? I am having the same concern and it looks like it is the weak point of bamboo... Thanks Guillaume

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events