Hi,
Is there a particular API useable from a bambo task plugin that would allow for formatting of the build number
If Bamboo starts with .1 we would like to format this to .001 in Bamboo using the plugin. We may have 4-5 build tasks for a particular build and the buildnumber needs to be formatted to 3 digits for all the tasks.
I understand there was no way to do this from an NAnt script and pass it back to bamboo.
Atlassian suggested a creating a plugin to do this. I am not able to see anything in the API that allows for this.
Community moderators have prevented the ability to post new answers.
Lance, do you mean the build number that is provided by Bamboo?
Hi James, Yes.
We have a sql update process that runs build db migration scripts. So we have a migration script from build .001 to .002, .002 to .003, etc.
If we can format the buildnumber then build 2 and build twenty wont look the same (.2 and .20)
We would like to take bamboos build number, format it and pass it back to Bamboo for use during the rest of the build tasks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We created a function in a build file that we included into our other NAnt scripts that handles converting the integer build number from Bamboo. Here is that function
<?xml version="1.0"?>
<!-- Generated by NAntBuilder v2.0-->
<!-- =================================
Project: FormatBuildNumber
Author : Lance Lyons
Onlife Health Solutions
Required inputs: Unpadded Buildnumber
Output: Build.version = Buildnumber padded with 0's to fill 3 digits
This script will take a buildnumber and format it to a certain
number of digits
The default will be 3 digits.
To change to a longer build number say 4 or 5 digits then update the statement below in the C# code
sTemp = releaseprefix+"."+String.Format("{0:000}", buildnumber);
to
sTemp = releaseprefix+"."+String.Format("{0:0000}", buildnumber);
or
sTemp = releaseprefix+"."+String.Format("{0:00000}", buildnumber);
for 4 and 5 digits respectively.
================================= -->
<project name="FormatBuildNumber" default="main">
<loadtasks assembly="C:\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll" />
<property name="build.number" value="" readonly="false" />
<property name="build.releaseprefix" value="" readonly="false" />
<script language="C#" failonerror="true">
<code>
<![CDATA[
[Function("fFormatBuildNumber")]
public static string fBuildnumberfunc(string releaseprefix, int buildnumber)
{
//String sTemp= new String;
string sTemp;
sTemp = releaseprefix+"."+String.Format("{0:000}", buildnumber);
return sTemp;
}
]]>
</code>
</script>
<property name="build.version" value="${script::fFormatBuildNumber(build.releaseprefix,build.number )}" readonly="false" />
<target name="main" >
<echo message='Build version is ${build.version}'/>
</target>
</project>
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.