TFS/Visual Studio Online API

As I was looking for API reference for TFS Release Management, I came across this useful link that I wanted to pass along. Visual Studio Online REST API Reference page (https://www.visualstudio.com/en-us/integrate/api/overview) includes API reference for TFS components like build, work item tracking, version control/GIT, load test, test management, shared services, etc. Basically, it includes reference for all existing API hooks for TFS/VSO.

I have also found this blog post (http://blogs.msdn.com/b/aseemb/archive/2014/12/23/how-to-program-against-release-management.aspx), which includes the API reference for TFS release management. It includes sample code that allows you to create a user, environment, release path, release definition, etc. Please note that release management (like build) is changing quite a bit in TFS 2015, so it's safe to assume that the API for build and release management will also be changing. Visual Studio Online REST API Reference page should have the latest changes, so just use it as a reference :)

If you haven't already seen it, look at the information on getting started with these APIs.

Gartner’s Public Cloud Storage Services

 

Microsoft Named a Leader in Gartner's Public Cloud Storage Services for Second Consecutive Year

Check out the details in Nicole Herskowitz's Blog.

VS 2015 Goes RTM!

 

 

You are invited to join an online event on July 20th to learn about the new features and technologies coming with this release. No registration is required! Just follow the link and save the date on your calendar! There will be live Q&A session with the VS developers involved in building the app after the pre-recorded show video. 

   

Visual Studio Release Event

   

 

For more details about Visual Studio 2015, check out the VS 2015 feature topics available here.

PowerShell & TFS

There have been occasions where I've wanted to create work items in bulk.

For example: Every time you create a User Story your team has several standard Tasks that need to be created. Write Test Cases, Execute test cases, Deploy to QA, etc. I don't want to manually go through dozens or work items adding the same set of work items as children to each one over and over.

Excel is a pretty good option, certainly faster than doing it one at a time via Team Explorer or the Web interface. In the past I have written C# applications to do this through the TFS API. This works great and is very easy to code.

I am always trying to force myself to get better with PowerShell, so I started searching for examples of calling the TFS API from PowerShell. This helped me piece together the parts I needed to solve this problem with PowerShell.

These were my requirements:

  • There are N Stories in TFS each one represents an existing report that needs to go through several stages of work.
  • We want 6 new Stories created as children of each Report Story so the work can be assigned to different teams in the organization then the individual teams can create their own tasks.
  • We don't want the Child Stories to all have the same title. That is fine when you see them in context of their parent like this:
    • Report 1
      • Report Attributes
      • Data Lineage
      • Gap Analysis
    • Report 2
      • Report Attributes
      • Data Lineage
      • Gap Analysis
  • However when you see the Report Attributes Story on its own it means very little.
  • Therefore I want was something like this:
    • Report 1
      • Report Attributes for Report 1
      • Data Lineage for Report 1
      • Gap Analysis for Report 1
    • Report 2
      • Report Attributes for Report 2
      • Data Lineage for Report 2
      • Gap Analysis for Report 2
  • Plus each sub story needs to have the same Area, Team and other attributes as its Parent Story

As you can see a simple cut and paste in Excel won't do, because I would still have to edit each work item to add the report name to the title and populate the fields from the parent that I want brought over.

PowerShell to the rescue

if ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )

{ Add-PSSnapin Microsoft.TeamFoundation.PowerShell }

 

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Common")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client")

 

#Get the TFS Collection

$tfsCollectionUrl = "http://Server:8080/tfs/CollectionName"

$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionUrl)

 

#Get the WorkItemStore Service

$ws = $teamProjectCollection.GetService([type]"Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore")

 

#Get the Team Project

$proj = $ws.Projects["Team Project"]

 

Write-Host "Team Project Collection: "$teamProjectCollection

Write-Host "Project:" $proj.Name

Write-Host "---------------------"

 

#Write a query to get the parent work items

$ParentWorkItems = $ws.Query("SELECT [System.Id] FROM WorkItems WHERE [System.AssignedTo] = 'Dave Lloyd' ")

 

#the Sub Stories you want to create as Children

$ChildStoryTitles = @( "Report Attributes","Data Lineage","Gap Analysis","Impact Analysis","Remediation","Testing")

 

#For each Parent Work item

foreach ($WorkItemParent in $ParentWorkItems)

{

$counter=1

Write-Host "Parent workItem:" $WorkItemParent.ID "-" $WorkItemParent.Title

 

#For each Parent create 6 New User Stories

foreach ($childTitle in $ChildStoryTitles)

{

$story = $proj.WorkItemTypes["User Story"]

$workitemChild = $story.NewWorkItem()

#Append the Parent Title to the end of the Child Title

     #System fields like title can be referenced directly and show up in intelliSence

$workItemChild.Title = $childTitle + " for " + $WorkItemParent.Title

#There is an order so I used a counter to set the Stack Rank on the CHild Stories

#For non-system fields use the fields member the name of the field and the value property

$workItemChild.Fields["Stack Rank"].value = $counter

#take any fields from the parent that you want to bring down into the child

$workItemChild.AreaId = $WorkItemParent.AreaId

$workItemChild.Save()

 

Write-Host " Child workItem" $workitemChild.ID $WorkItemChild.Title

 

#Link the CHild work item to the Parent Work item

$linkType = $ws.WorkItemLinkTypes[[Microsoft.TeamFoundation.WorkItemTracking.Client.CoreLinkTypeReferenceNames]::Hierarchy]

$link = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemLink($linkType.ReverseEnd, $workitemParent.ID)

$workitemChild.Links.Add($link)

$workItemChild.Save()

$counter++

}

 

}

 

DevOps Self Assessment

Microsoft has released a DevOps self-assessment online tool that allows you to gauge your readiness in the 7 key DevOps practice areas. Complete the form below to step through the assessment and see your results including guidance on which areas to focus on next. Total time commitment is approximately 10 minutes. DevOps self-assessment tool can be found at http://devopsassessment.azurewebsites.net/

TFS 2015 build/release agent install and configure

Installing TFS 2015 hosted build/release agent is extremely easy:

  1. Open TFS Web Access
  2. Click on Settings in the top right corner
  3. Click on project collection in the breadcrumbs
  4. Click on Download agent link to download .zip file with build/release agent in it. Right click on downloaded .zip file, click on Properties and Unblock the files if it is blocked
  5. Now the tricky part, the installation of build/release agent is essentially unzipping the file into a folder. Please make sure that you unzip the file into a folder that is not under your user profiles (for example, Downloads or Documents) or Program files folders, because this will cause UAC to kick in when build/release job will try to call to build/release agent. So, unzip folder somewhere like D:\BuildAgent\. Once you've unzipped the file into a folder, you have installed build/release agent. Now we need to configure it.
  6. Open PowerShell (preferably as administrator), and browse to the folder where you unzipped the build/release agent
  7. Run ConfigureAgent.ps1 and follow the wizard

That's it. Easy…

Drop location in new TFS 2015 build

In the new TFS 2015/VSO build, you can save the output to the server or to the good old drop location. If you would like to use the drop location, you will need to remember to specify how you would like the output to be stored. What I mean is that you will have to specify in the build definition the folder structure you would like to create. For example, instead of \\servername\drop, you will need to specify \\servername\drop\$(Build.DefinitionName)\$(Build.BuildNumber)\

There are quite a few system/metadata variables in TFS 2015, but that will be another blog post.

UPDATE: There is now Publish Build Artifact action in new TFS Build that you should use to control where and how your build output is produced.

P.S. : If you're not using new TFS 2015/VSO build system, you should give it a try. It's awesome.

TFS and PowerShell

It has been a while since we were able to write PowerShell scripts against TFS. For those who has not tried it yet, give it a shot. It's actually very easy to use and powerful tool. For those who has not tried PowerShell yet, I strongly encourage you to do that. There is no escape, PowerShell is everywhere J

Anyways, here is what you need to do to be able to write PowerShell script against TFS:

  1. Make sure you have PowerShell 3.0 installed or better. PowerShell is part of Windows Management Framework. To get PowerShell 3.0, you need to download and install Windows Management Framework 3.0 from https://www.microsoft.com/en-ca/download/details.aspx?id=34595. You might have to reboot your machine after this install.
  2. You also to download and install Windows PowerShell Cmdlets. This tool provides a Windows PowerShell interface that supports basic version control commands and a pipeline and glue to enable scripting. Windows PowerShell Cmdlets for TFS are part of Microsoft Visual Studio Team Foundation Server Power Tools that can be found at https://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f. Just make sure that you pick PowerShell component during the install.

That's it. Happy scripting.

//Build/Toronto

Couldn't go to //Build/? Not to worry Build is coming to you.

June 12th at the Design Exchange you can see Joe Stegma, Jeff Burtoft, Nikola Metulev and Vlad Kolesnikov deliver a day of sessions from Build.

Agenda

8:00 - close

Registration

8:00 - 9:00

Breakfast

9:00 - 10:30

Keynote

10:30 - 10:45

Break

10:45 - 11:45

Session #1 Universal Windows Platform

11:45 - 12:45

Lunch

12:45 - 13:00

Challenge

13:00 - 14:00

Session #2 Microsoft Edge & Web Apps

14:00 - 15:00

Session #3 Lightning Talks

15:00 - 15:30

Break

15:30 - 16:45

Panel Q/A

16:45 - 17:00

Closing remarks

 

Register here or if you can't get there but would like to join the Live Webcast register here.

It’s back and it is going to be awesome!

ObjectSharp's At the Movies event is back in town. It's is going to be awesome! And, not just because of the good looking and courageous Captain America in the last event poster. J So, mark May 13th in your calendar and join us for the free and highly informative geek event. As usual, it will cover all the latest and greatest technologies:

  • The new TFS 2015 with its new completely overhauled build and release tools, improvements to backlog management, the kanban board, the task board, card customization and more. A lot more… And, yes, the long awaited project rename capability… Presented and demoed by Microsoft MVPs in Visual Studio ALM - Dave Lloyd and Max Yermakhanov
  • All the latest and the most excellent changes to Azure, and there are quite a few of those… Presented and demoed by Shane Castle
  • All the coolest and most amazing technical news and changes that were announced in Build 2015 that would be relevant to you now and in the near future… Presented and demoed by Lori Lalonde

As I said, it will be awesome! And, it's not just for developers. It's for DevOps as well. It's for any IT person who had a pleasure to work with Azure or Team Foundation Server. Think about, Dave's and my session will cover builds and deployments using TFS. That's DevOps and Ops. Shane's session will cover Azure. That's again, DevOps and Ops related. Lori's and Dave's session will have quite a bit of DevOps and Ops goodness too.

So, don't wait. Register today at http://www.objectsharp.com/atm! It's free! it's fun! And, you will learn a thing or two J