Overview

Check-in policies are client-side code modules that are run during check-in, before changes are sent to the Team Foundation Server. In Teamprise Explorer, policies are Eclipse plug-ins installed to the Explorer's runtime environment. All Teamprise installations include a standard set of basic check-in policies, the Standard Check-in Policy Pack. Since these policies are already installed, you can skip to the Configuring Check-in Policies section below and start using them. You can also install custom check-in policies that you develop with the Teamprise Check-in Policy SDK.

You must have ProjectAdmin rights to configure a check-in policy on a team project. See Permissions Note for details.

Configuring Check-in Policies

Check-in policies are configured with the Teamprise Explorer or Teamprise Plug-in for Eclipse. Because of a difference in the way configuration data is stored, the Visual Studio Team Foundation Client cannot be used to configure Teamprise check-in policies. To configure policies on a team project, choose Check-in Policies... from the context menu in the Team Explorer view.

When the Check-in Policies dialog appears, click Add... to choose from a list of available policies. Some policies have settings that you can configure when you add the policy to the list. You can also edit these settings later by selecting the appropriate list item and clicking Edit.... Some policies (like the Changeset Comments Policy) do not have any settings you can edit.

The following image shows two policies configured on the Inventory team project. Clicking OK saves this policy configuration to the Team Foundation Server.

Permissions Note

Policy configuration data is stored in Team Foundation Server, as an annotation on the team project's source control item. You need ProjectAdmin permissions on a team project to successfully define a check-in policy for it. When you configure a check-in policy for a team project, other Teamprise users who have that policy installed will have it run automatically during check-in. Teamprise users who do not have that policy installed will receive a check-in policy warning. This warning must be overridden for check-in to continue. See the Installing Custom Check-in Policies section for more information.

Enabled

As an alternative to removing a policy definition entirely, a policy can be disabled by clicking on the check box in the left-most column in the list. Disabled policies are not run by Teamprise clients during check-in, but any settings you have configured on the policy are not lost. Click on the check box again to re-enable a policy.

Priority

Policies have a numeric priority assigned to them which affects the order in which they are evaluated by Teamprise. Policies with lesser value priorities (for example, negative numbers) run before policies with greater value priorities (for example, positive numbers). Priorities default to 0 but can be adjusted to negative or positive numbers. Policies with the same priority level run in an unspecified order with respect to each other.

To set a policy's priority, simply click in the priority column in the list and enter the new value.

It is important to note that a pending change set may include changes from multiple team projects, each of which may have check-in policies configured. When Teamprise evaluates the policies for the affected changes, it creates and sorts a list of all policies for all affected projects by priority. Since numeric priorities have a large range, you can configure a policy to run before other policies (even in other team projects) by giving it a very high priority (a negative priority value).

Scope

A policy can be constrained to a subset of the source control items inside a team project. Click the Scope... button to edit the scope of the selected policy. In the Scope Expressions dialog, add regular expressions (that match item server paths) to define the scope of the policy. If there are no expressions defined, all items in the team project match and are evaluated. If there is at least one expression defined, only the items whose server path matches any of the expressions are evaluated.

Use the text box near the bottom of the dialog to test server paths against the current list of expressions. The result text area is updated with information about how the server path matches the expressions. Click OK to save the scope expressions.

Running Check-in Policies

Teamprise runs any configured check-in policies automatically when pending changes appear. Simply click on the Policy Warnings tab in the Pending Changes view to view the current policy status of pending changes. Changes that do not comply with configured policies result in warnings printed in this tab. To remove the warnings and check-in your changes, make changes to your pending change set to comply with the policy warnings. You can check-in a pending change set that includes policy warnings if you override the warnings (see Overriding Policy Warnings).

The following image shows the Policy Warnings tab when no changes conflict with policy rules.

The following images shows the pending changes and the warnings created when the Check for Comments policy is enabled and the Forbidden Patterns policy is configured to disallow all files that match the regular expression .*\.junk.

Overriding Policy Warnings

If you want to check-in pending changes that do not comply with the configured check-in policies, perform the check-in operation like you normally would (see Check In for instructions). Teamprise will raise the Policy Failure dialog.

Provide an override comment and click OK to complete the check-in.

Installing Custom Check-in Policies (Explorer)

Custom check-in policies for Teamprise Explorer and Teamprise Plug-in for Eclipse are packaged as Eclipse plug-ins. These plug-ins must be installed manually to the Teamprise Explorer runtime directory in order to be available for configuration and evaluation.

To install a custom policy plug-in:

  1. Find the directory where you extracted the Teamprise Explorer archive
  2. Extract the custom policy plug-in archive into this directory, ensuring that the archive contents that are features are now inside the existing features directory, and the contents that are plug-ins are now inside the existing plugins directory
  3. Restart Teamprise Explorer (if running)
  4. Check the list of available policies for the new policy plug-in

Listing Available Policies

You can view a list of all check-in policies available to Teamprise Explorer using the Help > Teamprise Support... menu item. In the Teamprise Support dialog that appears, select the Diagnostic Data tab, then scroll down and click on the Teamprise > Available Check-in Policies item. The list on the right will contain all check-in policies the Teamprise Explorer found when it started.

If a policy you recently installed does not appear in this list, restart Teamprise Explorer so it can find the new plug-in. Also, check the appropriate log files in the Teamprise Logs tab for errors that may have occurred when loading the policy.