Pregunta

I am setting up a perforce server in my company, and wanted to implement the "change list" pre-filled description(similar to commit template in GIT), but online reference says that I need to do the same by the help of triggers. I figured out that I need to implement change-content and change-submit type or triggers. But all the documentation I found on the internet tells me only in a very raw form but not in an elaborate way. Even no video reference was present on the internet.

I would appreciate a lot, if someone can help me on how to create a trigger for the same.(This is my first time in Perforce Management.)

For reference the template would contain the following text:-

[BUG_ID]
[TITLE]
[SOLUTION]
[DEVELOPER]
[TEAM]

Thanks in advance.

Jayesh

EDIT (30 JUL 2014)-----------------------
After Byran's answer, I tried the following stuff. I added the following line in text file after firing 'p4 triggers'


template_setter form-out change "c:/test/p4_template.ps1 %changelist%"

and put the following code in the ps1 file

(Get-Content $args[0]) | 
Foreach-Object {$_ -replace "/<enter description here>", " Issue:
'nComment: "} | 
Set-Content $args[0]


But when I try to save the trigger file, it says "syntax error". And I am totally stuck at this point. as on internet I found almost every example saying I have to do this way. But this way is not working.

EDIT2 (30 JUL 2014)-----------------------
I figured out that I left out the 4 blank spaces before the trigger name in trigger file. After which it accepted the trigger. But now the problem is the code inside(as mentioned above) is not working. P4V gives me an error that the above file is not an valid WIN32 application.

EDIT3 (30 JUL 2014)-----------------------
I have fixed the EDIT2 problem by adding powershell before the trigger file path in trigger file. Now my trigger is execution or not I am not sure. Secondly, I am not sure if it is executing correctly.

Please help. Thanks

¿Fue útil?

Solución 2

Finally, I have figured out the whole process.
It goes as follows(Windows PowerShell based solution):-

Step 1 : Create a PowerShell script file(eg test.ps1) and put this code in it
(Get-Content $args[0]) | Foreach-Object {$_ -replace "<enter description here>", "template text"} | Set-Content $args[0]

Step 2 : Save this file to the physical server(try not to have a path with spaces) (eg. in my case file was located at c:\triggers\p4_template.ps1 on the physical server)

Step 3 : run this command on command prompt with super access to P4
p4 triggers

Step 4 : put this text in the text file just opened as a result of Step 3
<template_name> form-out change "powershell c:/test/p4_template.ps1 %formfile%"
(DO NOT FORGET TO PUT 4 WHITE SPACES before the <template_name>)
(you can put any template name with out spaces using hyphen and/or underscore)

Step 4 : run this command on command prompt with admin rights to command prompt on physical server
set-executionpolicy remotesigned

Step 5 : restart the Perforce service from Services.msc or restart the entire server once.

Step 6 : check the implementation from P4V client application.

This implementation worked 100% correctly. Hope this helps you as well.

Special thanks to Bryan Pendleton, who gave me the kick start in my work.

(please note that if you find any extra blank spaces in the code segments I have given then please ignore until and unless I have explicitly mentioned it.) Please vote if you find this helpful.

Otros consejos

You want a 'form-out' trigger for the 'change' form.

Try googling for

perforce form-out trigger example change

Here's a link, with the results restricted to forums.perforce.com: http://www.google.com/search?q=perforce+form-out+trigger+example+change+site:forums.perforce.com

And here's a link for broader results: http://www.google.com/search?q=perforce+form-out+trigger+example+change

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top