How to label as part of a build script

A collection of information about Vault, including solutions to common problems.

Moderator: SourceGear

Post Reply
dan
Posts: 2448
Joined: Wed Dec 17, 2003 5:03 pm
Location: SourceGear
Contact:

How to label as part of a build script

Post by dan » Mon Dec 29, 2003 4:02 pm

Build scripts are often designed to label a folder's contents within source control and then do a "get by label" to a local build folder before actually doing the build. This allows others to later see which version of a file or folder are associated with a given build, and also ensures that the files retrieved from the repository for the build are in a known state.

To do this from Vault, integrate the two command line client commands below into your build script. The parameters assume you are applying the label "My Label" to the Vault folder "$/Automated Tests" in a Vault Repository called "QA" and your build process looks for source files in "C:\builds\sourcetree". Also, your vault server is located at vault.company.com

Code: Select all

vault label -host vault.company.com -user "Build User" -password  "MyPassword" -repository "QA" "$/Automated Tests" "My Label"

Code: Select all

vault getlabel -host vault.company.com -user "Build User" -password  "MyPassword" -repository "QA" -destfolder "C:\builds\sourcetree" "$/Automated Tests" "My Label"

If your build script is in Perl, it might look something like this:

Code: Select all

$labelname = "Build $buildMajor.$buildMinor.$buildRev.$buildnum";

runprog( qq(vault label -host ${Vault_Server} -user ${Vault_User} -password  ${Vault_Password} -repository "${Vault_Repository}" "$Config->{'SrcDir'}" "$labelname") );

runprog( qq(vault getlabel -host ${Vault_Server} -user ${Vault_User} -password  ${Vault_Password} -repository "${Vault_Repository}" -destfolder ${BuildDir} "$Config->{'SrcDir'}" "$labelname") );

sub runprog
{
	my($progstr) = @_;

	output("EXECUTING " . ${progstr});

	open(DEBUG, ${progstr} . ' |');
	while(<DEBUG>)
	{
		print;
	}
	close(DEBUG);
}
For more information on the command line tool, use the "vault.exe help" command.

Post Reply