This integration script demonstrates how to use the SCM Adapter to create an integration with Subversion.
This is a post‐commit script that gets executed either from or as the hooks or post‐commit trigger.
#!/bin/sh # Location of SOURCEFORGE_HOME SOURCEFORGE_HOME="/opt/collabnet/teamforge/sourceforge_home" # The Hostname of the application server SOURCEFORGE_SOAP_HOST="ctf.open.collab.net" # The port used for soap communication SOURCEFORGE_SOAP_PORT="8080" # The "Repository Path" of the repository to commit to. SOURCEFORGE_REPOSITORY="myrepository" # The external system id of the integration server. SOURCEFORGE_SYSTEMID="exsy1001" # Path to the svnlook command SVNLOOK=/usr/bin/svnlook # Path to the CommitTool.py command COMMITTOOL="$SOURCEFORGE_HOME/integration/CommitTool.py" # If the author metadata of the commit is empty, use this user. This will normally # happen if a commit occurs that bypasses authentication DEFAULTUSER="admin" # Repository storage path. This is passed in by Subversion REPOS="$1" # Transaction id of this commit. This is passed in by Subversion TXN="$2" # Execute an svnlook log to get the Commit Message of this commit LOGMSG=`"$SVNLOOK" log -r "$TXN" "$REPOS"` # Execute the svnlook command to get the author of the commit if any. AUTHOR=`"$SVNLOOK" author -r "$TXN" "$REPOS"` if [ "X$AUTHOR" == "X" ]; then AUTHOR="$DEFAULTUSER" fi $SVNLOOK changed -r "$TXN" "$REPOS" | ( # Create a CommitTool transaction. "$COMMITTOOL" create "$SOURCEFORGE_SYSTEMID" "$SOURCEFORGE_REPOSITORY" "$AUTHOR" \ "$SOURCEFORGE_SOAP_HOST" "$SOURCEFORGE_SOAP_PORT" if [ $? -ne 0 ]; then exit 1; fi read TYPE FILE # Iterate through each line of the svnlook changes command and add a file with # the appropriate status to the CommitTool.py transaction. while [ "X$TYPE" != "X" ]; do # default to Added COMMAND="Added" case "$TYPE" in U) COMMAND="Modified" ;; D) COMMAND="Deleted" ;; A) COMMAND="Added" ;; esac "$COMMITTOOL" add "$FILE" "$TXN" "$COMMAND" >> /dev/null if [ $? -ne 0 ]; then exit 1; fi read TYPE FILE done # Submit the current transaction to sourceforge with the commit message. "$COMMITTOOL" commit "$LOGMSG" >> /dev/null if [ $? -ne 0 ]; then exit 1; fi ) if [ $? -ne 0 ]; then exit 1; fi exit 0