Thứ Tư, 24 tháng 7, 2013

Format build number from bamboo number

 https://answers.atlassian.com/questions/19648/changing-the-build-number-format

http://stackoverflow.com/questions/17174505/propertyregex-not-able-to-capture-numbers



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>

Không có nhận xét nào:

Đăng nhận xét

Học lập trình web căn bản với PHP

Bài 1: Các kiến thức căn bản Part 1:  https://jimmyvan88.blogspot.com/2012/05/can-ban-lap-trinh-web-voi-php-bai-1-cac.html Part 2:  https://...