17 12
发新话题
打印

[推荐] 建议大家把用过的trigger和HOOK共享出来!( 此文章被查看:3290次,被回复:16篇!! )

建议大家把用过的trigger和HOOK共享出来!

建议大家把用过的trigger和HOOK共享出来!
当然我们会为提供者积分和论坛金钱的奖励!我们是为了资源的共享!不是商业化的哦!希望大家支持!



© 本文为 听雨屋檐人SCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员
clearcase+clearquest个人博客:听雨屋檐人的博客
听雨屋檐人的淘宝小店!:听雨屋檐人的淘宝小店,欢迎光临

TOP

我们还就只用了禁止删除的
mktrtype -element -all -preop rmelem,rmname -nuser **,...,** -c "不允许删除元素,如确有必要,请通知管理员删除该元素" -execwin "ccperl D:\mktrigger\normelem.pl" NO_DELETE



© 本文为 刘刘SCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员
i am on my way ....

TOP

忘了刚才的代码了……
复制内容到剪贴板
代码:
#提示没有权限提示该项操作
$comment="$ENV{'CLEARCASE_COMMENT'}";
$errmsg="You have no permission to do so!Please contact SCM manager";
#If null comment,display error message and exit
$_=$comment;
system("clearprompt proceed -prompt \"$errmsg\" -mask proceed -prefer_gui");
exit 1;
本帖最近评分记录



© 本文为 刘刘SCMLife 共同所有,未经同意,请勿转载 ©如该文侵犯了您的版权,请联系管理员
i am on my way ....

TOP

UPDATE_WORD_DOC_PROPERTIES

发一个我刚刚整理的,更多的内容我会陆续整理出来!
http://liu6545.bokee.com

This trigger script is expected to be called from a pre-op checkin trigger.
Create an element all trigger that applies only to keyword_file element_types like:
    cleartool mktrtype -ele -all -pre checkin -eltype ms_word \
          -c "Updates Word Document properties..." \
          -exec "{path}/perl {path}/UPDATE_WORD_DOC_PROPERTIES.pl" UPDATE_WORD_DOC_PROPS
复制内容到剪贴板
代码:
############################################################
#
# UPDATE_WORD_DOC_PROPERTIES.pl
#
# Update/Add Custom Word Document properties during a during a checkin.
#
#   * Existing properties are updated if needed
#   * Requested but not existing properties are added and initialized
#
# End User Customization Notes:
#
# To add/remove/modify custom properties modify: %CUSTOM_PROPERTIES
#
# Arguments: None
############################################################
# History: 10/12/2005 : Created for A Better Solution, Inc.
############################################################
############################################################
###################################
########  Site Static Data ########
###################################
$OS="$ENV{'OS'}";
if ($OS =~ /[Ww]indows/)
{
   $CLEARTOOL   = "cleartool";
   $CLEARPROMPT = "clearprompt";
   $TFILE       = "c:\\temp\\update_word_doc_properties_$$.txt";
}
else
{  
   ####################################################
   # no modifications done for UNIX word doc checkins #
   ####################################################
   exit (0);
}
#################################
########  Passed In Data ########
#################################
        # NONE #
##################################
########  Calculated Data ########
##################################
$USER     =  lc ("$ENV{'CLEARCASE_USER'}");
$PN       =     "$ENV{'CLEARCASE_PN'}";
$XPN      =     "$ENV{'CLEARCASE_XPN'}";
$VIEW_TAG =     "$ENV{'CLEARCASE_VIEW_TAG'}";
############################
########  Test Data ########
############################
        # NONE #
################################
########  KEYWORD Data  ########
################################
   ########################################################################
   # custom_properties.  Obviously "you" can remove or add properties to  #
   # taste or change what is stored in the keyword to taste.              #
   #                                                                      #
   # What ever the property is to be built from should already be         #
   # calculated by now and defined above.                                 #
   #                                                                      #
   # (examples)                                                           #
   # clearcase_Id      => "$XPN by the user $USER"                        #
   # clearcase_view    => "$VIEW_TAG"                                     #
   ########################################################################
%CUSTOM_PROPERTIES = (clearcase_Id      => "$XPN by the user $USER",
                      clearcase_view    => "$VIEW_TAG"
                     );
#####################################
########  Other Global Data  ########
#####################################
$FALSE = 0;
$TRUE  = 1;
############################
########  Test Data ########
############################
        # NONE #
#############################
########  PROCEDURES ########
#############################
sub gripe   
{
   ##############################################################
   # Terminal error. Display the message using clearprompt and  #
   # the GUI if available if not then display to command line.  #
   # Exit with error code.                                      #
   ##############################################################
   local  ($gripe_prompt, $gripe_return) = @_;
   printf ("NOK\n$gripe_prompt \n");
   $gripe_prompt="\"$gripe_prompt\"";
   `$CLEARPROMPT yes_no -mask abort -default abort -pre -pro $gripe_prompt`;
   exit ($gripe_return);
}
########################
########  MAIN  ########----------------------------------------------------------------
########################
require 5.001;
use Win32::OLE;
use Getopt::Long;
##################
# Initialization #
##################
$msoTypeString = 4;
$do_update     = $FALSE;
printf ("Updating word document properties for ($PN)...");
####################################################
# Get Word application object and set destuctor to #
# shutdown even if perl program dies.              #
####################################################
$word_app = Win32::OLE->new("Word.Application", sub {$_[0]->Quit;});
if (!$word_app)
{
   gripe ("Warning: Can't start Microsoft Word application, document version info not updated....", 1);
}
###########################################################################
# Open the document invisibly and change the required document properties #
###########################################################################
$word_app->{Visible} = $FALSE;
$word_app->Activate();
if (($doc = $word_app->Documents->Open($PN)) == NULL)
{
   #########################
   # User rejects the open #
   #########################
   exit(1);
}
if($doc->{ReadOnly} == $TRUE)
{
  gripe("This Word document is already open for editing, document version cannot be updated at this time!", 2);
}
#########################
# Add/Update properties #
#########################
$doc->Activate;  
  
if (!$doc->CustomDocumentProperties)
{
   gripe ("WARNING:  No Custom document properties for word document ($PN)...\n", 3);
   ###################################################
   # You might choose to do something different here #
   ###################################################
}
#########################################
# Inspect each expected custom property #
#########################################
foreach $property (keys(%CUSTOM_PROPERTIES))
{
   if ($doc->CustomDocumentProperties($property))
   {
      if ($doc->CustomDocumentProperties($property)->{Value} == $CUSTOM_PROPERTIES{$property})
      {
         ##################################
         # Property unchanded - retain it #
         ##################################
         ; # Nothing to do for retention of this property #
      }
      else
      {  
         ################################
         # Property changed - update it #
         ################################
         $doc->CustomDocumentProperties($property)->{Value} = $CUSTOM_PROPERTIES{$property};
         $do_update = $TRUE;
      }
   }
   else
   {
      ####################################
      # Property new - add/initialize it #
      ####################################
      if ($doc->CustomDocumentProperties->Add($property, $FALSE, $msoTypeString, $CUSTOM_PROPERTIES{$property}))
      {
         $do_update = $TRUE;   
      }
      else
      {
         gripe ("Could not add required property ($property) to ($PN)", 4);
      }
   }
}
##################################
# Update/save document if needed #
##################################
if($do_update == $TRUE)
{
   $count = $doc->Fields->Count();
   for ($i=1; $i<=$count; $i++)
      { $doc->Fields($i)->Update(); }
   $doc->{Saved} = $FALSE;
   $doc->Save();
}
###############################
# Close document and continue #
###############################
$doc->Close();
printf ("...OK\n");
exit(0);

© 本文为 听雨屋檐人 所有,未经同意,请勿转载
©如该文侵犯了您的版权,请联系管理员
clearcase+clearquest个人博客:听雨屋檐人的博客
听雨屋檐人的淘宝小店!:听雨屋檐人的淘宝小店,欢迎光临

TOP

VOB_OWNER_ONLY

在发一个整理过的:

http://liu6545.bokee.com

Make sure only the current VOB owner can perform certain VOB actions.

Create an element all trigger and apply
to specified operations like:
复制内容到剪贴板
代码:
cleartool mktrtype -ele -all -pre checkin -brtype main \
          -c "Prevents checking on main branch by anyone except the current VOB Owner." \
          -exec "{path}/perl {path}/VOB_OWNER_ONLY.pl" VOB_OWNER_ONLY
or make a element trigger type and apply as needed:
复制内容到剪贴板
代码:
cleartool mktrtype -ele -pre checkout \
          -c "Prevent anyone but the current VOB owner from checkout of certain files." \
          -exec "{path}/perl {path}/VOB_OWNER_ONLY.pl" VOB_OWNER_ONLY_ON_DEMAND

    cleartool mktrigger VOB_OWNER_ONLY_ON_DEMAND foo.c bar.c
or make a type trigger to prevent certain action from being performed:
复制内容到剪贴板
代码:
cleartool mktrtype -type -pre mktype -brtype -all \
          -c "Prevent anyone but current VOB owner from creating branch types in the VOB." \
          -exec "{path}/perl {path}/VOB_OWNER_ONLY.pl" VOB_OWNER_ONLY_TRIGGERS
复制内容到剪贴板
代码:
############################################################
#
# VOB_OWNER_ONLY.pl
#
# Make sure only the current VOB owner can perform certain VOB
# actions.
#
# Note:
#
# Arguments: None
#############################################################
# History: 01/29/2005 : Created for A Better Solution, Inc.
############################################################
############################################################
###################################
########  Site Static Data ########
###################################
$OS="$ENV{'OS'}";
if ($OS =~ /[Ww]indows/)
{
   $CLEARTOOL   = "cleartool";
   $CLEARPROMPT = "clearprompt";
}
else
{
   $CLEARTOOL   = "/usr/atria/bin/cleartool";
   $CLEARPROMPT = "/usr/atria/bin/clearprompt";
}
#############################
        # NONE #
#################################
########  Passed In Data ########
#################################
        # NONE #
##################################
########  Calculated Data ########
##################################
$USER   =  lc ("$ENV{'CLEARCASE_USER'}");
$VOB_PN =     ("$ENV{'CLEARCASE_VOB_PN'}");
$OP     =     ("$ENV{'CLEARCASE_OP_KIND'}");
############################
########  Test Data ########
############################
        # NONE #
#############################
########  PROCEDURES ########
#############################
        # NONE #
########################
########  MAIN  ########----------------------------------------------------------------
########################
##################
# find VOB_owner #
##################
@data = `$CLEARTOOL desc -l vob:$VOB_PN`;
@lines = grep (/^    owner /, @data);
$lines[0] =~ s/^\s+//;
chomp ($lines[0]);
($trash, $long_owner) = split (/[\ ]/, $lines[0]);
@parts = split (/[\\\/]/, $long_owner);
$owner = lc $parts[$#parts];
if ($owner ne $USER)
{
   $prompt="\"Only the current VOB owner can perform the $OP command in this VOB ($VOB_PN).\"";
   `$CLEARPROMPT yes_no -mask abort -default abort -pre -pro $prompt';
   exit 1;
}
exit 0;

© 本文为 听雨屋檐人 所有,未经同意,请勿转载
©如该文侵犯了您的版权,请联系管理员
clearcase+clearquest个人博客:听雨屋檐人的博客
听雨屋檐人的淘宝小店!:听雨屋檐人的淘宝小店,欢迎光临

TOP

clearcase十大经典triggers!

clearcase十大经典triggers!发布出来共享给大家!

http://liu6545.bokee.com

Preventive triggers

ClearCase contains some very powerful commands, and you may want to limit access to them in a particular ClearCase installation. The following trigger shows how to prevent some project users from initiating a specific ClearCase command.

1. Rmelem trigger

The cleartool rmelem command is one of the most powerful commands in ClearCase because it removes a complete element from version control. This command destroys information irretrievably. Using it carelessly may compromise your organization's ability to support previous releases.

Since this command can be so destructive, the cleartool rmname command should be used in its place in almost all cases.

It's probably pretty clear why this is one of the first commands on which I like to put a trigger.

Trigger installation / Trigger script

Here is the trigger definition:

cleartool mktrtype -c "Trigger to avoid rmelem command" -element -all -preop rmelem -execwin "ccperl -e \"exit 1\"" -execunix "Perl -e \"exit 1\"" NO_RMELEM

The trigger script is pretty straightforward: it simply invokes the ClearCase embedded Perl interpreter and exits with a status of false, so the ClearCase command rmelem cannot be executed.

Usage

When a user tries to execute the rmelem command, the following message appears:


Z:\rdn>cleartool rmelem test.txt
CAUTION! This will destroy the element, all its branches and versions,
including all data, meta-data and history, and will remove the element
from all directory versions that now contain it.  Once you destroy the
element, there will be no way to restore it to its current state.
If you want to preserve the element, but remove references to it from
future directory versions, use the "rmname" command.
Element "test.txt" has 1 branches, 4 versions, and is entered
in 1 directory versions.
Destroy element?  \\\\\[no\\\\\] yes
cleartool: Warning: Trigger "NO_RMELEM" has refused to let rmelem proceed.
cleartool: Error: Unable to remove element "test.txt".
Z:\rdn>



Post-operation triggers

Post triggers perform an action after a ClearCase operation, to ensure that the action occurs in conjunction with the operation. For instance, you may want an e-mail notification sent after check-in or check-out. Following is a list of triggers that perform common post-operation actions.



你可以通过这个链接引用该篇文章:http://liu6545.bokee.com/viewdiary.13799181.html

© 本文为 听雨屋檐人 所有,未经同意,请勿转载
©如该文侵犯了您的版权,请联系管理员
clearcase+clearquest个人博客:听雨屋檐人的博客
听雨屋檐人的淘宝小店!:听雨屋檐人的淘宝小店,欢迎光临

TOP

Change_owner.pl

# Automatically change element's owner as the VOB's
$hostname = $ENV{COMPUTERNAME};
$vobname = $ENV{CLEARCASE_VOB_PN};
$filename = $ENV{CLEARCASE_PN};

$owner = `cleartool describe -long vob:\"$vobname\" | findstr owner`;
$owner = substr($owner, rindex($owner, "\\")+1);
$group = `cleartool describe -long vob:$vobname | findstr group`;
$group = substr($group, rindex($group, "\\")+1);


if ($owner ne "") {
        system("cleartool protect -cho \"$owner\" -chg \"$group\" \"$filename\"");
}
本帖最近评分记录

© 本文为 flyee_cn 所有,未经同意,请勿转载
©如该文侵犯了您的版权,请联系管理员

TOP

Lock after checkout except for the devloper and specified person

# To automatically lock the element after checkout
$user=$ENV{CLEARCASE_USER};
$elName="$ENV{\"CLEARCASE_PN\"}";
$eltype="$ENV{\"CLEARCASE_ELTYPE\"}";

#Directory name must be in lower case
if ($eltype ne "directory") {
        system("cleartool lock -nuser \"$user\",other_users \"$elName\"");
}
本帖最近评分记录

© 本文为 flyee_cn 所有,未经同意,请勿转载
©如该文侵犯了您的版权,请联系管理员

TOP

Make sure that the activity about to be performed is commented at least $ARGV[0] words. If not dissallow the action.

############################################################
# This trigger script is expected to be called from any pre-op trigger.
#
# Either create an element global trigger and apply
# to specified operations like:
#
# cleartool mktrtype -ele -glo -pre checkin -brtype main \
# -c "All checkins on the main branch must have a 20 word comment"
# \
# -exec "FORCE_COMMENT.tgr 20" COMMENT_MAIN_20
#
# or make a element trigger type and apply as needed:
#
# cleartool mktrtype -ele -pre checkin \
# -c "Checkins on selected critical files must be commented 40
# words." \
# -exec "FORCE_COMMENT.tgr 40" COMMENT_CRITICAL_40
#
# cleartool mktrigger COMMENT_CRITICAL_40 critical.c essential.c
#
# or make a type trigger to make sure certain actions are commented:
#
# cleartool mktrtype -type -pre mktype -trtype -all \
# -c "Creation of new trigger types must be commented 50 words." \
# -exec "FORCE_COMMENT.tgr 50" COMMENT_TRIGGER_50
#

$OP = "$ENV{'CLEARCASE_OP_KIND'}";

if( length($ENV{'CLEARCASE_COMMENT'}) <= $ARGV[0] )
{
$prompt="\"This controlled action ($OP) must be commented to a minimum of
$ARGV[0] words!\n\"";
`clearprompt yes_no -mask abort -default abort -pre -prompt $prompt`;
exit 1;
}
exit 0;
本帖最近评分记录

© 本文为 小鱼 所有,未经同意,请勿转载
©如该文侵犯了您的版权,请联系管理员

TOP

cleartool mktrtype -element -all -preop checkout -c "force reserved checkout" -execwin "ccperl \\LM38-r\CCScript\forcereservedcheckout.pl" force_reserved

############################################
#
#Force reserved checkout and Unreserved checkout is forbidden
#
############################################

$res ="$ENV{'CLEARCASE_RESERVED'}";


if($res == 1)
{
        exit(0);
}
else
{
              $prompt="\"Unreserved checkout is forbidden.\n\"";
              `clearprompt yes -mask abort -default abort -pre -prompt $prompt`;
        exit(1);
}
本帖最近评分记录

© 本文为 小鱼 所有,未经同意,请勿转载
©如该文侵犯了您的版权,请联系管理员

TOP

 17 12
发新话题