Search code examples
triggersclearcase

How do I write a ClearCase trigger that launches a batch script?


I am an extreme novice when it comes to ClearCase triggers but I am very used to working with ClearCase.

I would like to write a trigger that will fire when a user checks in a file and launch a batch script that is on the ClearCase server. I assume that the trigger will somehow provide me the ID of the activity that is being used and the stream as parameters, so I need to learn how to use these.

Where can I find a tutorial? I've found some documentation but it doesn't really help me. I need a step-by-step sort of guide both for programming (with code examples) and for setting it.

Thank you!

Andrew


Solution

  • It is a postop checkin trigger, and you can see some of them in the "IBM Rational ClearCase: The ten best triggers" page:

    cleartool mktrtype -c "Trigger to check the checkin" -element -all -postop checkin -execwin "ccperl \\server\triggers\check_checkin.bat" -execunix "Perl /net/server/triggers/check_checkin.pl" CHECK_CHECKIN
    

    You can see all the environment variables you can use in a script launched by a trigger in the page "mktrtype".
    It includes:

    • CLEARCASE_ACTIVITY: The UCM activity, if applicable, involved in the operation that caused the trigger to fire.
      For checkin, checkout, and uncheckout operations, the activity that is set in the view used for the operation.
    • CLEARCASE_STREAM: The UCM stream containing the object involved in the action that caused the trigger to fire, if applicable.

    Note: the OP Andrew mentions that:

    The CLEARCASE_STREAM EV is only valid for All deliver, rebase and mkbl operations; mkactivity, chactivity, rmactivity, setactivity, mkstream, chstream, rmstream, chbl, and rmbl operations.
    With the checkin operation it returns NULL.

    In that case, you could use the CLEARCASE_VIEW_TAG EV in order to get the stream name:

     # Windows Syntax
    cleartool lsstream -view %CLEARCASE_VIEW_TAG%
     # Unix Syntax
    cleartool lsstream -view $CLEARCASE_VIEW_TAG