Calling Perforce Tasks within build scripts login problem

Using Perforce and ANT:

When attempting to call p4 tasks within our own ANT build scripts and utilizing the 'Do not check out files automatically' option of VCS checkout mode, I am continually running into the problem where the P4 login information is not being recognized.

I have set the environment variables through TeamCity:

The error message received is:
error: Perforce password (P4PASSWD) invalid or unset.
Problem exec'ing P4 command: error: Perforce password (P4PASSWD) invalid or unset.

We are using ticket-based authentication on the Perforce server, and this is the same error message received through the VCS Root screen if we do not check the 'Use ticket-based authentication' checkbox.

One way we've gotten around the problem is to call a remote task (telnet or psexec) to establish a session into the build agent and then it will recognize our login variables.

Any ideas or tips to get around this problem?


Comment actions Permalink

How long are your tickets valid for? By default they time out after 12 hours, which would force you to login over and over

We had the same problem with ours (only using Visual Studio and Perforce though). If it's the same, there's a setting in VS under Options -> Source Control -> Plug In Settings -> Advanced -> Connection (or something close to that) which allows you to disable the pop-up window and bind to your perforce environment.

We also had to make sure that if you're spawning a new process that they are spawned as direct child processes and not somewhere else and that they are spawned under the same login name as Team City (Ie we were forced to login into Team City under a specific account, not the SYSTEM account).

Hope that helps.

Comment actions Permalink

Could you use Ant's "exec" task and call p4 commands that way? I tried the following and it worked for me:



I have a feeling that any p4 Ant task can be called this way. You can probably adapt "echo SUPERSECRETPASSWORD|p4 -u USERNAME login" to the "exec" task to perform the login. I think you will avoid the ticket issue because you will be logging in every time. Of course, anyone with access to your build file will know the password, but that may be the price to pay for convenience.

Hope this help,

Comment actions Permalink

I have a setup similar to henwo with Ant and Perforce. Has anyone done any Perforce checkins as a result of building a project in TeamCity? I have a project that generates some artifacts that need to be checked in upon success. The problem for me is that I am using direct mapping to the agent in TC build configuration (//depot/... //team-city-agent/...) without a workspace. Ant's p4 tasks require a client workspace to run (the example I wrote below used Ant's "]]>" setting for p4 parameters with an already-defined workspace). If anyone has an answer for this, that would be very helpful.

Edited by: Oleg Gerovich on Sep 11, 2008 1:29 PM


Please sign in to leave a comment.