Hi all,
I'm writing a proof of concept Bamboo Task module having started from the basic HelloWorld example in the documentation. To begin I just want to log out some key build information.
We want to access Bamboo build/plan variables like bamboo.buildNumber, bamboo.custom.svn.revision.number as well as usernames and things but I'm struggling to find any examples of this in the documentation.
I looked at a few maps from the TaskContext object which were all empty including:
An example would be great to show how these should be accessed (and if one of the above should not be empty).
Thanks in advance!
Community moderators have prevented the ability to post new answers.
VariableContext variables = taskContext.getBuildContext().getVariableContext();
VariableDefinitionContext variable = variables.getEffectiveVariables().get("release_new_tag");
String newTag = variable.getValue();
Through above was able to access the bamboo custom variable "release_new_tag" - define for the specific plan
For access bamboo variables should use methods provided by sdk. e.g. taskContext.getBuildContext().getBuildNumber();
Your snippet helps me to figure out how I can access my variables.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can inject an instance of CustomVariableContext
into your task and then use the following to get the build variables:
Map<String, String> buildVariables = customVariableContext.getVariables(taskContext.getCommonContext());
Hope this helps.
Kind regards,
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can look these up via taskContext.getBuildContext().getCustomDataMap().get() but take off the bamboo. prefix before looking them up (eg instead of bamboo.buildNumber it is simply buildNumber)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi James,
Thanks for the reply. That 'getCustomDataMap' method doesn't seem to exist on the BuildContext object though? I had a look and couldn't see anything similar (other than the 3 maps I listed above which didn't work).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.