Introduction
Microsoft Visual Studio Team System 2008 is an integrated application lifecycle management (ALM) product family with the tools and processes that help development teams work more effectively together.
Microsoft Visual Studio Team System 2008 Team Foundation Server (TFS) is a team collaboration platform that combines team portal, version control, work-item tracking, build management, process guidance and business intelligence into a unified server. It allows everyone on the team to collaborate more effectively and deliver better-quality software.
Version Control is one of the key elements of Team Foundation Server apart from Work Item Tracking, Project Management, Build Automation and Reporting. In TFS, we can enforce Check-in policies on projects. A Check-in policy is a requirement for developers to perform one or more tasks on code before it is allowed to be checked into the version control system.
Policies can be enforced such that work items are associated with the check in or unit tests are being run or that code analysis is performed before check-in.
In this article, let me show how to enforce check-in policies on Team Projects in TFS 2008 in a step by step manner.
Steps
Open Team Explorer and connect to the Project.
Right click on the project --> Team Project Settings --> Click on Source Control.
Refer to the screenshot below:
The Source Control Settings window opens up.
You can allow multiple check-outs in the first tab “Check-out Settings”, to allow parallel development.
Then click on the tab “Check-in Policy” to set the check-in policy on the project.
In the “Check-in Policy tab”, click on “Add” button to add the relevant check-in policies as per the project requirement. Select the Policy from the list of available policies and click the “OK” button.
Here, I have selected Code Analysis policy. Once Code Analysis policy is selected, it would ask to select the Rule sets for Code Analysis. Select the relevant rules for your project’s code analysis and click on “OK” button. Refer to the screenshot below:
Then, I selected the “Work Items” policy, such that the developer or any team member needs to associate a work item with the check-in. Work Items are the fundamental way of allocating task to team members in TFS. For example, the Project Manager can allocate a task like “Add Login Screen” through Work Items in TFS. So once the developer completes the task, while checking in, the developer can link the Work Item “Add Login Screen” with the relevant check-in.
Once all the policies are defined, click on “OK” button in the Source Control Settings window.
Now, add the Project / Solution to the TFS Project Source Control.
Then in the development environment, if the User tries to check-in any file(s), she/he will get the “Check-In – Source Files” window. Refer to the screenshot below. This window lists the collection of files being checked in. User can put in comments, check-in notes and associate Work Items with the check-in. With every Check-In on TFS, a Changeset is created on the server with a unique numeric ID. So a Changeset is a collection of check-in files along with work items and other relevant information.
Next, once any user tries to check-in any file(s), without fulfilling the requirements defined in the check-in policy for the project, she will get a Policy Failure warning. Refer to the screenshot below:
However, there are many occasions where we need to check-out for certain purposes where policy binding does not make any sense. TFS allows the user to override check-in policy with a reason. Refer to the screenshot below. But this should not be a prelude to override policy as the Project Manager can review the check-in logs and policy violations to detect the users who are not following the standard check-in policy.
To map with Work Items, any user can click on the Work Items button available in the “Check-In – Source Files” window. A user can select one or more work items by clicking the checkboxes available with the Work Items and then click on “Check-In” button. Refer to the screenshot below:
If the check-in policies are followed, the system should allow check-in to the server without any further warning.
Conclusion
In this article, we learnt about Check-in policies in TFS and how to enforce and follow the same. You can learn more about the TFS version control features from my article Version Control in VSTS 2008.
To learn more about the features of VSTS and TFS, please refer to this URL.
History
- 24th August, 2009: Initial post