In our shop here we set the weekly Build number in our products version
based on when we start development of that version.  In order to get
this build number into our build process we were updating a source code
file at the beginning of our build cycle using xmlpeek and xmlpoke.  Our
problem was that it would increment the build number every time it
built.  So our weekly build would get off if we built more than once a
week.  Then we would have to go back and manually change it back which
kinda defeated the fun of an automatic process.  So I thought "Hey I can
do some date math and get this right."  And this is what I came up with
so I figured I would share.

<property name="dayz" value="${datetime::now()}" />
<property name="startweek" value="${datetime::parse('5/20/2006')}" />
<property name="weekly"
value="${(timespan::get-days(datetime::parse(dayz) -
datetime::parse(startweek)) -
datetime::get-day-of-week(datetime::parse(dayz)) )/7 }" />
<echo message="Your weekly build number for ${dayz} is ${weekly} !" />

This starts the weekly on Sunday 5/20/2006 00:00:00 and works like a
charm.  Now we can build our weekly all week long. (not my ideal way of
doing a weekly build, but the reality of it)

Later,
Kurt Frank


Reply via email to