Run and Deploy Custom Check-in policy using TFS SDK 11 for Java
Posted by: Subodh Sohoni ,
on 4/20/2012,
in
Category VSTS & TFS (Azure DevOps)
Abstract: In this article we will explore how to debug and run a custom check-in policy using TFS SDK 11 and then deploy it on a developer’s machine.
In the last article, we created a custom check-in policy using TFS SDK 11 for Java. In this article we will explore, how to debug / run that policy and then deploy it on a developer’s machine.
Now that the coding of the check-in policy is over, let us see how to debug that. To debug a plugin, we have to create a Run Configuration. Open the Run configuration editor from Run menu.
Click the Eclipse Application and click on the New Run configuration icon. This action will create a configuration and open it for editing. Change the name to CP_Configuration. We can use the same configuration for Debug too from Run > Debug Configurations or you may as well create it as Debug Configuration. In addition to name change, also check the checkbox against the Plugin that I had created earlier (the check-in policy).
Now, when we click on the Run button (or Debug button if we are in Debug configuration), it starts another instance of Eclipse and allows us to Run or Debug the plugin. In this new instance, we can now check if the Check-in Policy is available and does it work or not. Open menu Help > Team Explorer Support.
In the property pages that appears, select Diagnostic Data tab and then under the node of Team Explorer, select Available Check-in Policies. In the list of check-in policies, we can see the newly created custom check-in policy for Code Review.

Clos these pages and select Team Foundation Server Exploring perspective. Then connect to a Team Project (in my case SSGS EMS) and from the settings page, select Check-in Policies. When you click on the Add button, it shows the newly created custom check-in policy.

Just select the newly created custom check-in policy and click OK. Code Review policy is shown as enabled.
To test that check-in policy, we will make a small change in the code of SSGS EMS team project.

Now when we attempt to check-in that pending change, check-in policy evaluation will fail and in the Policy Messages tab, it displays that Check-in is not allowed since Code Review check-in policy is not satisfied.

Deploying the Custom Check-in Policy
Now that we are satisfied that this check-in policy works, let us deploy it. After closing the second instance of Eclipse, export the check-in policy so that it can be deployed. First set the release version to 1.0.0.0 in the manifest (META-INF\MANIFEST.MF). Then select File > Export from menu.
In the wizard that started, select Plug-in development > Deployable Plugin and Features.
In the wizard that started, select Plug-in development > Deployable Plugin and Features.
On the next page, check the checkbox against the created check-in policy plugin and then select the radio button to export it into an archive. Create a folder (D:\Java\Created Plugins) to hold the archives of the plugins that we selected, gave the name to the archive as ‘Code Review Check-in Policy’ and click on the Finish button. In the target folder, this plugin archive is created as a zipped archive.
Now let us deploy it to the regular instance of Eclipse (not the one that is used for plugin development). Open the main folder of Eclipse and drill down to the folder named ‘dropins’ . The JAR that is in the.zip file that was created by the export wizard, is copied in this folder.
Now we can Add the Code Review Check-in Policy from the settings
And if you try to check-in without associating the code review work item the policy gets evaluated and the warning is shown in the Pending Changes window, Policy warnings tab.
Summary:
To create a TFS 11 Custom Check-in Policy, you need to follow these conditions:
1. Download and install
2. Add TEE 11 for Eclipse for Plugin Development too
3. Create a Plugin project
4. Add JAR that is provided in TFS SDK 11 as referenced library
5. Configure plugin with Dependencies and Extension Point
6. Extend the PolicyBase class in to plugin class.
7. Implement all overridable methods. Main logic of check-in policy should go in the Evaluate method
8. Trial Run or Debug can be done using Run / Debug configuration
9. Deploy the plugin by first exporting it in the archive and then copying that JAR in the dropins folder of Eclipse.
This article has been editorially reviewed by Suprotim Agarwal.
C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.
We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).
Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.
Click here to Explore the Table of Contents or Download Sample Chapters!
Was this article worth reading? Share it with fellow developers too. Thanks!
Subodh is a Trainer and consultant on Azure DevOps and Scrum. He has an experience of over 33 years in team management, training, consulting, sales, production, software development and deployment. He is an engineer from Pune University and has done his post-graduation from IIT, Madras. He is a Microsoft Most Valuable Professional (MVP) - Developer Technologies (Azure DevOps), Microsoft Certified Trainer (MCT), Microsoft Certified Azure DevOps Engineer Expert, Professional Scrum Developer and Professional Scrum Master (II). He has conducted more than 300 corporate trainings on Microsoft technologies in India, USA, Malaysia, Australia, New Zealand, Singapore, UAE, Philippines and Sri Lanka. He has also completed over 50 consulting assignments - some of which included entire Azure DevOps implementation for the organizations.
He has authored more than 85 tutorials on Azure DevOps, Scrum, TFS and VS ALM which are published on
www.dotnetcurry.com.Subodh is a regular speaker at Microsoft events including Partner Leadership Conclave.You can connect with him on
LinkedIn .