EDIT: removed the period.We've had lots of requests from customers who want to be able to hook into the Vault server to catch events. Since Sourcegear can't meet everyone's need's exactly, I wanted to provide a small example plugin, which could be modified to do more useful work, such as notifying an email address, or starting an automated build. Two things to note:
1. Sourcegear still plans on writing plugins to ship with Vault and those will be fully supported. We're not going to ask everyone to write their own email plugin, for example. This is just a kick start for those Vault users who know what they want and want it now.
2. As we write our plugins, we may change the plugin API and architecture. Don't count on this API staying constant. When or if we do change the API, expect me to update this example with the new way of doing things.
The template can be found at here.
Setting this up is a bit complicated, as it is a Web Service.
1. Unzip the template to somewhere on disk.
2. In IIS Manager, create a virtual directory named PluginServiceTemplate that points to the directory that holds the PluginServiceTemplate.asmx file.
3. Load the solution file. Build the solution. If there are any problems building, verify that the references point to the correct locations on disk. By default, the VaultPluginLib reference points to c:\inetpub\wwwroot\VaultService\bin, and all others point to c:\program files\Sourcegear\Vault Client.
4. Start debugging. When the Web Service page comes up, click on UpdateVaultConnectionInformation. Fill in the hostname, username, and password that you wish to use to connect to your Vault server. Hit the Invoke button will set the connection information.
5. Go back to the Web Service page. Click on UpdateRepositoryInformation. Fill out the repositoryName and pathToWatch fields. Hit Invoke again.
6. Go back to the Web Service page. Click on RegisterWithServer. Type in the password for the user "admin" on the Vault Server that you specified above. Hit Invoke. If no longer wish to have the Vault server call the plugin, you must call UnRegisterWithServer.
Now that you're set up, you should be able to put a breakpoint in the OnEndTx method in PluginServiceTemplate.asmx.cs, and when a change is made to the repository that you're watching while you're debugging, the breakpoint should be hit. There are four methods that a plugin can define.
The example only overrides OnEndTx, since that's the most interesting of the four. When the plugin is informed that a transaction has finished, OnEndTx walks through the following steps.
1. Log in to the Vault server and refresh the tree cache.
2. Use FindFolderRecursive (Remember that from last time?) to find the path to watch.
3. If the version number on that object is different that the last version number we saw, run a history query to find out what changed in the last transaction.
4. Loop through all of the VaultHistoryItems. Right now that loop is empty.
Note that if all you want is a plugin that kicks off a new build, you can probably skip the history query.
EDIT: updated the plugin code with the URL fix discussed below.