Server hooks

This topic describes server hooks.

Overview of 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 the post-commit server hook, and the post-update server hook in 17.3.

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

The post-update script (available in versions: 17.3 and later) will be executed after every Task update. The script must be copied to the post-update.bat file located in the ServerHooks folder under your repository path.

The post-update batch file script will be executed for every Task update with the following arguments:

  • argument 1 - Project Name
  • argument 2 - View Name
  • argument 3 - User Name
  • argument 4 - Class Name (i.e., Task)
  • argument 5 - Transaction Time (using machine local time)
  • argument 6 - Transaction ID
  • argument 7 - Project ID
  • argument 8 - View ID
  • argument 9 - Item ID
  • argument 10 - Class ID
  • argument 11 - Task Number
  • argument 12 - Task Name
  • argument 13 - Responsibility (i.e., User Name )
  • argument 14 - Status (integer)

Back to top

Sample post-commit scripts

There are a couple of 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-update.batSends an email notification and starts Jenkins build for each task update.
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.

Back to top