Friday, May 31, 2019

Internal extensions in TFS

Some of the TFS Azure DevOps functionality that comes out of the box is internally organized the same way third party extensions are. You can even see their manifests:

use Tfs_Configuration;
select p.DisplayName, p.PublisherName, e.ExtensionName,
    e.DisplayName, e.ShortDescription, cast(Content as varchar(max)) as Content
    from Gallery.tbl_Asset a
        inner join Gallery.tbl_Extension e on a.ReferenceID=e.ExtensionId
        inner join Gallery.tbl_Publisher p on e.PublisherId = p.PublisherId
        inner join tbl_FileReference r on a.FileId = r.FileId
        inner join tbl_Content c on r.ResourceId = c.ResourceId
    where AssetType = 'Microsoft.VisualStudio.Services.Manifest'
    order by e.ExtensionName, a.Version desc

I can see multiple versions of the same extension there, my TFS instance went through several version upgrades; on a freshly installed copy there would probably be only one.


One of the nicer touches is how the very contribution types are somewhat documented in those manifests.


Not everything you see in user extensible lists is present there, though. Specifically, the built-in service hook consumers - Trello, Slack, and so on - don't seem to be listed there. The reason I was wondering, surely those third party sites don't expose TFS aware REST endpoints; there must be some layer of translating the payload from TFS' own format to the target's. I was rather hoping that the manifests would provide some guidance how. However, the manifest that describes the consumer contribution type (the one for vss-servicehooks extension) claims that only the following fields are supported under the publishEvent:
  • url
  • headers
  • resourceDetailsToSend
  • messagesToSend
  • detailedMessagesToSend
With the exception of headers, those are all kind of documented., and the only options for the latter three are All, Minimal, or None.

There's a hint of a variable substitution functionality in the docs; in the sample hook consumer, they use {{{url}}} as the value of publishEvent.url, and there is also a user editable url input field listed under inputDescriptors. One presumes that {{{url}}} refers to the value of the latter. Can I similarly substitute properties of the original event?



UPDATE: looks the service hook consumers are baked into the C# code. There's an assembly Microsoft.VisualStudio.Services.ServiceHooks.Consumers.dll with namespaces exactly like those built-in service hooks - Slack, Trello, etc. Oh well. This particular avenue of extension is a private road.

No comments:

Post a Comment