Server Hooks

Server hooks are scripts that run automatically every time a particular event occurs in the StarTeam repository. Server hooks allow the user to trigger customizable actions at key points in the development life cycle.

StarTeam Server implements one server hook: post-commit

The post-commit script automatically runs after a Change Package status is set to commited. For example, you may want to use post-commit to send a notification email or to start a build.

The name of the script file is post-commit.bat on Windows and post-commit.sh on Linux. The script must be copied to the ServerHooks folder under your repository path.

After committing a change package, StarTeam Server checks the ServerHooks folder, within the repository directory, to see if a post-commit script exists. If yes, it will execute the script in a separate process.

The post-commit batch file script will be executed for every committed Change Package with the following arguments:
  • - argument 1 - Project Name
  • argument 2 - Target View Name
  • argument 3 - User Name
  • argument 4 - Class Name (i.e., ChangePackage)
  • argument 5 - Transaction Time (using machine local time)
  • argument 6 - Transaction ID
  • argument 7 - Project ID
  • argument 8 - Target View ID
  • argument 9 - Item ID
  • argument 10 - Class ID for ChangePackage
  • argument 11 - Source View ID
  • argument 12 - Source View Name
  • argument 13 - Change Package Name
There are a couple post-commit scripts samples installed in StarTeam Server installation directory under the ServerHooks folder:
post-commit - vcm replay.bat.sample
uses View Compare/Merge to rebase every change package to a specific sandbox.
post-commit.bat
sends an email notification for each change package committed.
To help debug post-commit scripts that you create:
  • When setting VerboseLevel to 1 in starteam-server-configs.xml for the configuration, the parameters for each call to post-commit will be written to the server log. It will look something like this:
     7 00000011 2017-06-22 15:57:24
    Launching c:\repository\test\ServerHooks\post-commit.bat
    ProjectName='test' ViewName= 'Myview' UserName=' joe'
    TransactionID=169859 ProjectID=5 ViewID=40 ItemID=15140 ClassID=89
    SourceViewID=40 SourceViewName='New view2' CPName='Workspace
    Changes for Change Request 1,206 test on 2017/06/22 22:55:35 GMT
    1498172135634'
    
    
  • If you redirect the output of your script to a file, make sure the file name is unique. Otherwise, multiple scripts executing in parallel will fail due the inability to access the output file.