0
votes

[Edit] You can get the current build-def via the IServiceProvider. See this answer. [/Edit]

I'm trying to add a custom editor for one of our TFS Xaml build workflows. I started by following this excelent tutorial by Ewald Hofman. Everything worked as expected, when I click on the [...] button for the workflow parameter the credential dialog is displayed.

What I want to do: I want to display a selectable list/tree of test suites that are available in the TFS team project. Just like in the Default Labs Workflow:

enter image description here

Obviously, for this to work, I have to be able to communicate the the TFS over its .Net-API (Is it possible to do via SOAP/REST?).

But whenI started to alter the example to fit to my scenario, I naivly tried using the IServiceProvider to get ahold of an IBuildService instance.

public override object EditValue(ITypeDescriptorContext context, ServiceProvider provider, object value)
{
            if (provider != null)
            {
                IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                IBuildServer bs = (IBuildServer)provider.GetService(typeof(IBuildServer));
                ...

This approach did not work, bs is null after this statement.

Then I tried to connect to the TestManagement like this:

            var pr = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfs:8080/tfs/DefaultCollection/ProjectName"));
            var TcmService = pr.GetService<ITestManagementService>();
            var t = TcmService.GetTeamProject("ProjectName");

But this failed with a HTTP 404 error that is displayed when I click the edit [...] buttton of the workflow parameter. The url is correct, if i open the page in a browser, the Team Webaccess page is displayed.

enter image description here

TL;DR:

I would like to be able to display a list of test suites of the current tfs in a custom worfklow parameter editor, but I am failing to connect to the TFS.

Other approach: This site (and some others) recommend using builtin editors. Is it possible to use the builtin editor window of the labs workflow paramaters (the one in the first screenshot)?

Thanks in advance.

1

1 Answers

0
votes

Appearantly I was just stupid.

var pr = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfs:8080/tfs/DefaultCollection/ProjectName"));

The project name must not be in this URL. With the line below it works just fine.

var pr = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfs:8080/tfs/DefaultCollection"));

See my followup question