[p4] automatically building in the latest changelist number for a build

Paul Andrei pandrei at foliage.com
Wed Mar 23 17:21:50 PST 2005


Our Continuous Build System, after it detects that a change has occurred 
in one of the monitored branches, does something like this:

1. increments build number
2. runs 'p4 changes -m 1 -s submitted //filespec/...'
3. parses the result and gets the last submitted change number
4. runs 'p4 sync -f //filespec/... at change'
5. builds the project
6. runs unit tests
7. e-mails the interested parties the build results and
    the actual version (//filespec/... at change)

TIP: it's important for steps 2, 3, and 4 to occur in this order. It's 
safer to find out what's the last submitted change number first and then 
fetch *that* version, than to fetch the latest version and then find out 
what was the last submitted change number. The later suffers from a race 
condition.

We don't currently embed the change number in the product's version, but 
it seems like a reasonable idea:

4+. put change number [and build number] in "version.h"

Paul Andrei


Leo Zelevinsky wrote:
> It feels certain that others have run into my design problem before
> and I don't want to reinvent the wheel.
> 
> We have recently moved from SourceSafe to Perforce. Recently, we have
> decided to adopt the perforce strategy for numbering versions - so
> that in the version label is built in the latest changelist that was
> used in making the build.
> 
> I am wondering what would be the best way to make this as foolproof as
> possible. For instance, I'd like our Help/About box to display the
> latest changelist checked in when this code was last synced. What's
> the best way to get at that information?
> 
> I am thinking that it should be something like a script I run as part
> of the sync which in addition to the sync would create a .h file with
> the latest changelist information (I guess gotten via p4 changes -m 1
> -s submitted).
> 
> Do others do this sort of stuff? Any tips?
> 
> Thanks!
> _______________________________________________
> Come to the 2005 Perforce User Conference, April 14 & 15 in Las Vegas.
> Learn more: http://www.perforce.com/conf 
> 
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user
> 




More information about the perforce-user mailing list