Question

I want to know if there is an in built functionality in Perforce which allows us to automatically check out code. I have multiple servers and I would like to have an option where, when I modify a script in one of the servers and check it into perforce, it automatically checks out the script out to the other servers.

Was it helpful?

Solution

There are three possible approaches here, subscription and polling and triggers.

Subscription

In this approach, you get Perforce to notify you when there's a change, and respond accordingly. However, the only notification you can get from Perforce is an email sent to a user account's email address. So you could configure the servers to respond to the email by running a p4 sync command. Microsoft Outlook Rules and Alerts (for example) can be configured to do this quite easily. This answer here and this documentation here shows you how to configure these email alerts.

Polling

In this approach, you simply write a short program (batch script, executable, whatever...) that runs constantly on your servers. It just sleeps most of the time, but wakes up and calls p4 sync every few minutes on the area of the depot you're interested in. This approach is simple, and doesn't involve any other third party applications. If you're using Windows, running as a service would be ideal, because it would then be able to start up automatically with the server, as well as allow you to 'start' and 'stop' it as required.

I'd say polling is probably your best bet here.

EDIT

Triggers

From @Matt's comment, it's worth considering a third option, that of triggers, which are documented here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top