4

I figured I'd post here, after posting on SuperUser, since I want to get input from software developers who might have encountered this scenario before!

I would like to initiate a series of validation steps on the client side on files opened within a changelist before allowing the changelist to be submitted.

For example, I wish to ensure that if a file is opened for add, edit, or remove as part of a changelist, that a particular related file will be treated appropriately based on a matrix of conditions for that corresponding file:

  • Corresponding file being opened for add/edit/remove
  • Corresponding file existing on disk vs. not existing on disk
  • Corresponding file existing in depot vs. not existing in depot
  • Corresponding file having been changed vs. not having been changed relative to depot file

These validation steps must be initiated before the submit is accepted by the Perforce server. Furthermore, the validation must be performed on the client side since I must be able to reconcile offline work with the copies on clients' disks.

Environment:

  • Perforce 2017.2 server
  • MacOS and Windows computers submitting to different branches

Investigative Avenues Already Covered

  • Initial design was a strictly client-side custom tool, but this is not ideal since this would be a change of the flow that users are familiar with, and I would also have to implement a custom GUI.

  • Among other approaches, I considered creating triggers in 2017.2; however, even if I were to use a change-content trigger with all the changelist files available on the server, I would not be able to properly perform the validation and remediation steps.

  • Another possibility would be using a change-submit trigger and to use the trigger script variables in 2017.2 to get the client's IP, hostname, client's current working directory, etc. so that you could run a script on the server to try to connect remotely to the client's computer. However, running any script on the client's computer and in particular operating on their local workspace would require credentials that most likely will not be made available.

I would love to use a change-submit trigger on the Perforce server to initiate a script/bundled executable on the client's computer to perform p4 operations on their workspace to complete the validation steps. However, references that I've found (albeit from years ago) indicate that this is not possible:

Thank you for reading and in advance for your help!

Wanda B.
  • 161
  • 2
  • 11
  • Unfortunately, this is probably off topic as it is a bit too broad – Derek Pollard Apr 08 '19 at 22:26
  • Hey @DerekPollard! Would you be able to give me some suggestions as to how I can refine my question? I could try to create a TL;DR that I need to know if someone has been able to do this, or if this is a limitation of Perforce's trigger mechanism :) – Wanda B. Apr 08 '19 at 22:28

1 Answers1

2

running any script on the client's computer and in particular operating on their local workspace would require credentials that most likely will not be made available.

This is the crux of it -- the Perforce server is not allowed to send the client arbitrary code to execute. If you want that type of functionality, you'd have to punch your own security hole in the client (and then come up with your own way of making sure it's not misused), and it sounds like you've already been down that road and decided it's not worth it.

Initial design was a strictly client-side custom tool, but this is not ideal since this would be a change of the flow that users are familiar with, and I would also have to implement a custom GUI.

My recommendation would be to start with that approach and then look for ways to decrease friction. For example, you could use a change-submit trigger to detect whether the user skipped the custom workflow (perhaps by having the custom tool put a token in the change description for the trigger to validate), and then give them an error message that puts them back on track, like "Please run Tools > Change Validator, or contact wanda@yourdomain.com for help"

Samwise
  • 68,105
  • 3
  • 30
  • 44
  • Haha yeah, shoot, that was the original plan: in order to force the submit to come through the custom tool, we'd have a trigger on the Perforce server to check. So there's no way to run code that already exists on the client machine using a change-submit trigger? i.e. change-submit causes script to be run on server, which then uses the connection that perforce already has open to client to run a script? Thank you so much for your guidance, Sam!! – Wanda B. Apr 08 '19 at 22:46
  • I mean, there's *always* a way. The most straightforward way would be to set up a microservice on each client and make sure the trigger has access to it. (That's the "punch your own security hole in the client" method -- any time you open up some new method of remote execution you want to think carefully about how it might be misused...) – Samwise Apr 09 '19 at 00:39