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)
Views: 87675
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.

run-configuration

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).

 

select-plugin

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.

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.

available-checkin-policy

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.

code-review-checkin

Just select the newly created custom check-in policy and click OK. Code Review policy is shown as enabled.

code-review-enabled

To test that check-in policy, we will make a small change in the code of SSGS EMS team project.

code-change

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.

pending-changes

 

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.

export-policy

In the wizard that started, select Plug-in development > Deployable Plugin and Features. deployable-plugin

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. plugins-fragments 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. export Now we can  Add the Code Review Check-in Policy from the settings checkin-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.

policy-warning

Summary:

To create a TFS 11 Custom Check-in Policy, you need to follow these conditions:

1. Download and install

  • Team Explorer Everywhere 11 in Eclipse
  • Eclipse for Plugin Development
  • TFS SDK 11 (for Java)

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.

Absolutely Awesome Book on C# and .NET

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!

What Others Are Reading!
Was this article worth reading? Share it with fellow developers too. Thanks!
Share on LinkedIn
Share on Google+

Author

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 .


Page copy protected against web site content infringement 	by Copyscape




Feedback - Leave us some adulation, criticism and everything in between!
Comment posted by Brandon on Friday, June 1, 2012 5:37 AM
@Subodh - Congratulations on your site completing 5 years. I have gained immensly from your tutorials and I just wanted to say "thank you"
Comment posted by Subodh Sohoni on Tuesday, June 5, 2012 12:14 PM
Thanks Brandon!
Comment posted by ram on Saturday, June 23, 2012 3:06 PM
Hi Subodh, I hope you can help me in this.
I want get TFS certified professional and have few questions in mind so could please answer below questions for me:
1)How many papers do i have attempt ?
2)What is the fee for exam ?
3)From where i can get study materials ?

Thanks
Comment posted by Subodh Sohoni on Sunday, June 24, 2012 10:33 AM
Hi Ram,
For TFS 2010 there is only one certification and one exam for that. It is 70-512 which is for TFS 2010 Administration. There is no exam for using TFS. For TFS 2012 there will be 3 exams which will be ready in another 4-5 months or so. You need to give this exam at Prommetric center. You can find one in your city. They will be charging aprx. USD 100 worth in your local currency (Aprx. 5000 Rupees if you are in India). Study material is not muc available. You can find the syallabus on Microsoft Learning site and for many of the topics you will find some videos on our website (http://www.ssgsonline.com/downloads.aspx).
Comment posted by Stu on Monday, May 13, 2013 1:27 PM
Hello, Great article thanks.  If a conflict should arise after evaluate method is called (I'm copying files from source at this point) and the developer decided to cancel checkin, do you have an idea on how the copy (already executed) could be rolled back?
Thanks!