views:

838

answers:

4

Hi,

I'm doing a project at uni and would like to create zip files which name (just a build number) increments after each successful build.

What's the easiest way to do this? Is it a case of having to write a custom task or is there some built in functionality that will allow me to do this, simply and easily?

I did have a look at the Zip task manual and couldn't spot anything that might be useful.

Any help appreciated.

Thank you,

+5  A: 

Have you seen the BuildNumber task?

Run that task and then name the zip file based on the property.

Jon Skeet
A: 

One easy alternative solution would be to include a timestamp into your file name:

myapp_20090326-1522.zip for the build made on 2009-03-26 at 15:22.

That's what many projects do. Also avoids problems if multiple people may create builds on their machines; you don't need to coordinate build numbers.

sleske
A: 

If you use a Hudson CI server to build your project, you can use the Hudson build number. Here's a quick example of getting the BUILD_NUMBER environment variable (which is injected by Hudson):

<property environment="env" description="System environment variables (including those set by Hudson)"/>
<!-- set the build number based on environment variable, otherwise blank -->
<condition property="buildNumber" value=".${env.BUILD_NUMBER}" else="">
    <isset property="env.BUILD_NUMBER" />
</condition>
Jeff Olson