BuildMaster uses the Perforce Command-Line Client (p4, or p4.exe on Windows) for
Perforce integration, and therefore the Command-Line Client must be installed on
the same server that BuildMaster is installed on, or installed on a server that a
BuildMaster agent is installed to. In either case (local or remote server), the
setup is the same.
Configuring the Perforce Client on Your Server
There are two clients that are freely available from Perforce: P4 and P4V. The
"V" in P4V stands for Visual, and contains both the P4 Command-Line Client and
a graphical interface. The visual client is easier to work with, especially if
you're not familiar with with all the various command-line options. We generally
recommend installing P4V, even though BuildMaster will only use P4.
A connection to a Perforce Server requires four key pieces of data:
-
User Name ("P4USER") - the username to login into the Perforce Server
-
Password ("P4PASSWD") – the user's password
-
Workspace Name ("P4CLIENT") – the server-defined workspace to use
-
Perforce Server ("P4PORT") – the server and port number
Creating a Client Workspace
A Perforce client workspace is a set of files on a machine that mirror a subset of the
files in the depot. Creating a client workspace is relatively simple from P4V, but it
can also be accomplished with P4 with the following steps:
md c:\p4workspaces\user1_workspace1
cd c:\p4workspaces\user1_workspace1
p4 –u {username} –p {password} –P {server:port} client user1_workspace1
The P4 command will cause a text editor (default: notepad) to open, and once you close
it the client workspace ("user1_workspace1") will be created. In future editions of the
BuildMaster Perforce Extension, we may automatically create this for you, but for now,
it requires a simple command.
Configuring Environment Variables (Optional)
Although it's easy to simply enter these four values in the BuildMaster source control
provider, you can also define these through P4 environment variables. Environment
variables are relatively easy to set-up and allow for even more fine-grained control
of P4, but they're defined per-user, which means that you must configure them for the
account that BuildMaster is running under.
For this setup, I have a Windows server called BMPERFORCESV2, which has the P4 client
installed and a BuildMaster agent running under the BUILDMASTERUSER account. To configure
the four P4 environment variables, I first logged-in to the server as BUILDMASTERUSER,
opened up a command-line, and executed four commands:
p4 set P4USER=user1
p4 set P4PASSWD=password1
p4 set P4CLIENT=user1_workspace1
p4 set P4PORT=bmperforcesv1:1666
To verify this setup, execute two p4 commands ("set" and "depots"), which should return
a list of the depots:
The list of depots shows that P4 was able to connect to the server successfully.
Configuring the BuildMaster Perforce Extension
The BuildMaster Perforce Extension works like most other source control extensions.
First, you'll need to create a source control provider. To do this, go to Admin >
Source Control > Add New Provider, and then select Perforce from the list.
After filling in the appropriate fields, a click of the "Test Connection" button
should verify that Perforce is connected.
Perforce and BuildMaster
In addition to being able to browse your Perforce depots from within BuildMaster,
there are three actions you can now use:
- Get Latest
- Get Labeled
- Apply Label
See Label and Tag Your Builds in Source Control with BuildMaster
for some best practices in chaining together these actions.
Continuous Integration
Like any other Source Control Provider in Buildmaster, you can also set-up a build schedule for
continuous integration.