1

I do have a script with check the format/style of the files. We used to run it on all elements every night using sort of night_script.

Now I want to add it to a preop trigger for checkin command. To do that per file(s) a switch is needed. How could I do so?

Example of how the script runs:

style_check -f file1 [file2 ... fileN]

I found this trigger creation command while searching but I don't know how to customize it :)

#execute a script on all text files after checkin:
ct mktrtype -element -all -preop checkin -eltype text_file -exec <path to script> PROCESS_CHECKIN
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

0

See "Is it possible to lock the applying label option for a work_branch in ClearCase?" for an example of preop trigger:

ct mktrtype -element -all -preop mklabel -exec "/path/to/script"

See also the Examples section of cleartool mktrtype

The trick is to use a shared path accessible by all ClearCase client workstations.

check the "Trigger operations and trigger environment variables" to find the right variable to pass as parameter to your script: in your case, CLEARCASE_PN

ct mktrtype -element -all -preop mklabel  -execwin "\\path\to\script \"%CLEARCASE_PN\"" and -execunix "/path/to/script $CLEARCASE_PN" 

Note the use of -execunix/-execwin to reference the same script (or a different script) per OS.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The quoting on the execunix and execwin clauses is wrong. It should be more like: -execwin "\\path\to\script \"%CLEARCASE_PN\"" and -execunix "/path/to/script $CLEARCASE_PN" You may want to include quotes on the Unix side as well, although unix folks generally don't put spaces in filenames. – Brian Cowan Aug 03 '18 at 20:38
  • @BrianCowan Thank you. I have edited the answer accordingly. – VonC Aug 03 '18 at 20:42