Fog Creek Software
Discussion Board

Clearcase integration - here it is

I haven't included site-configuration for linking back to clearcase for history and diffs reporting - you may be able to work out an easy way to use clearcase's own web-server, but we just wrote some simple scripts ourselves - Joel let me know if interested and I can email them.

Firstly here's the clearcase command you should run in each vob you want this feature - run this after you have created the file below:

# postop checkin for notifying fogbugz

/usr/atria/bin/cleartool mktrtype                      \
    -postop checkin                                    \
    -element -all                                      \
    -c "postop checkin checks" \
    -execwin "ccperl \\\\tncdev4\\opt2\\clearcase\\storage\\triggers\\"  \
    -execunix "/usr/atria/bin/Perl /net/tncdev4/opt2/clearcase/storage/triggers/" \

Just replace "/net/tncdev4" and "\\tncdev4\" with your path to the file below:

2ndly here is the perl script that does the work

# Actions you want to happen after a checkin.
# Search for a fogbugz id of the form "...bugzID:<num>" and tell fogbugz about it

use Socket;

# Change to name of BUGZ server
$BUGZ_SERVER = "www.myfogbugz";

# Change only if you aren't running on normal port 81
$BUGZ_PORT = "80";

# Change to top level URL for bugz server - must contain trailing slash
$BUGZ_URL = "/";

### That's all you have to do! ###

# Do not need to change this
$CVSSUBMIT = "cvsSubmit.asp";

$logmsg = "$ENV{'CLEARCASE_COMMENT'}";
$sFile = "$ENV{'CLEARCASE_PN'}";

$SUBJECT = $sFile;

# Get BUG number if its there
$ixBug = 0;
if ($logmsg =~ /(\s*)[Bb][Uu][Gg][ZzSs]\s*[Ii][Dd](\s)*[:;](\s*)([0-9]*)/)
    $ixBug = int($4);
    print "Adding fogbugz info for id# $ixBug ...\n";

# open a socket to the right port on the bugz server and submit
# data through a GET request

if ( $ixBug > 0 )
    # get previous version
    my($sPrev) = `/usr/atria/bin/cleartool desc -fmt '%PSn' $ENV{CLEARCASE_PN}\@\@/$sNew 2>/dev/null`;

    my $get = "GET http:\/\/".$BUGZ_SERVER.$BUGZ_URL.$CVSSUBMIT."?ixBug=".$ixBug."&sFile=".$sFile."&sPrev=".
    my $in_addr = (gethostbyname($BUGZ_SERVER))[4] || die("Error: $!\n");
    my $paddr = sockaddr_in($BUGZ_PORT, $in_addr) || die("Error: $!\n");
    socket(S, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die("Error: $!\n");
    connect(S, $paddr) || die("Error: $!\n");
    print S $get;

# ok to proceed
exit 0;

Steve Brown
Wednesday, October 29, 2003

It doesn't work.

The script wants to write the previous and new branch names to cvsSubmit; e.g. <snip>&sFile=main.cpp&sPrev=\main\ips_main\4&sNew=\main\2

The cvsSubmit fails because the fields for Prev and New are longer than expected. It's probably expecting just integer sized fields. It really doesn't make sense to just use just numeric version numbers in clearcase. Depending on how the branching is done, the numeric version numbers may not be sequential.

Too bad. ClearQuest integration with ClearCase is ugly and expensive. I was hoping to get something useful to work with FB.

Another option would be to just submit the &sFile component; but FB doesn't allow Prev and New to be blank. I guess I could fake it out and write "zero" versions for each check-in leaving the src diff page unimplemented. At least I could still link the source file to the change source.

Fred Medlin
Wednesday, April 07, 2004

Looks like sPrev and sNew fields are limited to width of 16 characters.

Fred Medlin
Thursday, April 08, 2004

*  Recent Topics

*  Fog Creek Home