The following variables are available to shell scripts
BUILD_NUMBER
The current build number, such as "153"
BUILD_ID
The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
JOB_NAME
Name of the project of this build, such as "foo"
BUILD_TAG
String of "hudson-${JOBNAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.

To understand how environmental variables provided by Hudson can be utilized by Ant, study the following target:

<target name="printinfo">
  <property environment="env" />
  <echo message="${env.BUILD_TAG}"/>
</target>