Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Anatomy of an Automation for the TFS Automation Platform

DZone's Guide to

Anatomy of an Automation for the TFS Automation Platform

·
Free Resource
If you can’t wait for the Tfs Automation Platform, but you still want to eventually deploy your extensions using it, what can you do?

We would really like for you to still be able to build out automations without the Automation Platform, but you would not have the delivery and management aspects. Hopefully this post will guide you on how you can integrate your work with the Tfs Automation Platform later.

 

note: This product is still under development and this document is subject to change. There is also the strong possibility that these are just rambling fantasies of a mad programmer with an architect complex.


Well, we will be integrating integrating with many of the TFS elements as proxies so that we can leverage existing code without having to rewrite things. For a rough understanding of the architecture and where you can start building things now lets look at the generic scenario:

  1. Installation

    Assemblies and other supporting files are dropped into the correct Plugins folder on the server

  2. Configuration

    There is some settings stored somewhere that will control how the process runs

  3. Action
    There are three types of action:

    1. User Action – The user deliberately setts a process running

    2. Event – An event is raised on the server (e.g. WorkItemChangedEvent)

    3. Schedule – A particular time is reached

  4. Processing

    Some amount of work is done

Installation

There are a number of places that you need to put files on the TFS Server to have them loaded effectively:

  • Event Handlers (ISubscribers) – C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\Web Services\bin\Plugins
  • TFS Jobs (ITeamFoundationJobExtension) – C:\Program Files\Microsoft Team Foundation Server 2010\Application Tier\TFSJobAgent\plugins\*

Our installation will be two fold. First is the download of the ".zip” archive containing all of the require files and unpacking them, probably to:

c:\Program Files\Microsoft Team Foundation Server Automation Platform\Automations\[Automationname]

The second stage will occur when an administrator “activates” the plugin for your server. This will look for a manifest file in the Automation folder that will tell it what components are part of the Automation. The installer will know where on the server the files need to go and deploy them to that location.

Configuration

For configuration we are probably going to have a class that holds the settings that is sterilised and stored in TFS as Property’s. This will allow us to have both static and instance config, but I would not worry about were these are currently stored as you will probably need to have your own storage mechanism for now. However, if you are curious on the current thinking:

Category Name Value
TfsIntegrationPlatform Generic Generic Integration Platform settings and configuration
TfsIntegrationPlatform Plugins List of installed plugins and their current status
TfsIntegrationPlatform Mappings List of TFS objects and which plugins are mapped to each one
TfsIntegrationPlatform-[Automation] Default Default and single instance settings
TfsIntegrationPlatform-[Automation] [Instance] Settings that pertain to an individual configured instance of an automation
     

Figure: Where will the data be stored

Any UI required to exit the plugin data will need to be included in the package and we have not yet decided how this should happen. With .NET it is a little more difficult to inject UI and it will probably end up being Silverlight.

image_thumb5
Figure: Injecting UI in Silverlight is easy

Action

Although there are a number of types of action, the goal is the same; to add a Job to the Job Queue in TFS that will do the processing. The action can be triggered either by the user or when an event is fired in TFS.

Server Side Actions

If it is a user interaction that caused the action then there was probably a Silverlight UI assembly or package stored within the installable Automation Package. When it was unpacked the new UI became available.

It it was a server event driven action then an assembly with a class that implements ISubscriber was installed to the Plugins folder of the website where it was loaded into the pipeline for events.

The result is that configuration will be added to “TfsIntegrationPlatform-[Automation]” that will be loaded by the TFS Job next time it is run.

NOTE: If you build normal server side event handlers then we will try to allow you to wrap them later with minimal code changes

Client Side Actions

If the action was based on a Check-In Event on the client or server then the assembly that contained the Check-In Policy was loaded into the correct place and the correct registry entries added. There was previously some progress in this direction with the Power Tools, but it was difficult to implement and little known.

NOTE: If you build normal CheckIn Policies we will try to allow you to wrap them later and deploy as part of an Automation package without having to change the code.

Processing

The processing is where the magic happens and in order to provided some level of robustness this should be run on the  TFS Job Agent (ITeamFoundationJobExtension) that can be restarted when the server is rebooted. Once the “Action” has updated the correct settings for the Automation the Job will queued. When the Job runs it will load its settings from at “TfsIntegrationPlatform-[Automation]” and run through each configured instance as needed.

The only communication between the outside world and the Job is through the settings stored as TFS Properties.

NOTE: If you build a ITeamFoundationJobExtension then we will try to allow you to wrap it later with minimal code changes

Conclusion

It should be possible for you to create iSubscribers, ITeamFoundationJobExtension and PolicyBase classes that perform your needs and we will allow you to package them separately or together with space for a UI and other functionality later.

There is no reason not to extend TFS now and once the TFS Automation Platform releases there will be no need to ever install another extension again Smile apart from the TFS Automation Platform itself…

Topics:

Published at DZone with permission of Martin Hinshelwood, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}