Missed Team ’24? Catch up on announcements here.

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

Changing the build number format

lance_lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2011

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.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
James Dumay
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 7, 2011

Lance, do you mean the build number that is provided by Bamboo?

lance_lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2011

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.

lance_lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2011

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>

TAGS
AUG Leaders

Atlassian Community Events