Thursday 29 January 2015

My first approach with open-source: TFSThemeUploader

To be fair, I’ve never been involved in open-source very much. I mean, personally. Moreover, I have always been quite shy of my stuff, as nowadays I mostly write scripts and no longer full-fledged production applications.

But anyway I decided to give it a go. So please, do not shoot the pianist, alright? :)

TFSThemeUploader is a simple PowerShell script aimed at automating the scenario described in this MSDN article. I’ve always thought it is quite tedious to manually complete, as it requires a bit of fiddling around XML and command-line tools. There is absolutely nothing wrong with it, but when you need to perform the same actions for more than one or two projects it isn’t very…compelling – hence the script.

I might expand it actually, to make it a bit more user-friendly and to expand the possible scenarios, I have a couple of ideas. But for the meantime, it is a good start I think.

Saturday 17 January 2015

Continuous-Integration-as-Infrastructure and Git Flow

This came out at Friday’s meeting of the London ALM User Group – can I set up an infrastructure CI build for my whole Git project, configured with Git Flow?

I think Git Flow is a great piece of tool for non-enthusiasts or anyway people with limited interest in understanding Git. It creates a naming convention skeleton for your branching strategy, and using SourceTree you can let this kind of users work on their stuff with limited supervision.

gitflow0gitflow1

So, thinking on it – can Team Build help? Of course it can!

If you select the appropriate Include statement for the branches you’d like in the Build Definition, it is literally one click away:

image

Doing so you are telling the Team Build to run a build (CI in this case) on the feature/* branch, where of course the star is a wildcard. Every branch you are going to create will benefit from it without any effort.

So you commit whatever you need, and the CI is already working for all you wish - given the mapping.

gitflow2 gitflow3

Wednesday 14 January 2015

Visual Studio Release Management as a Service – a quickstart

Let’s face it – cloud computing is utterly cool (pay-as-you-use service, near 100% availability, no infrastructure costs) but it is not for everyone. Even myself, I keep maintaining my own lab even if I use cloud services, both for learning and production purposes. But there are tools where the infrastructure and setup costs are not for everyone – think about Exchange.

IMHO Visual Studio Release Management is amazing, but its infrastructure and setup/maintenance cost might not be for every taste. That’s why having it as a Service in Visual Studio makes it even better!

If you install the Release Management Client on your machine, you just need to connect to Visual Studio Online instead of an on-premise server:

image

After you log on with your MSA, you will notice the URL automatically changing – that is VSRMaaS!

image

This is the only setting you have to care about. All the rest is managed by Visual Studio Online.

So, how can you use it? There are a couple of limits, for now. It is a beta, and it supports only vNext environments. A vNext environment is an agent-less deployment environment, which leverages PowerShell DSC. Eventually, it can be both in the cloud or on-premise. After that, it’s all the usual VSRM stuff…

image

The caveat is that you need to use DSC – hence no pre-existing activities but just your own scripts:

image

These scripts are going to feed the Release Pipeline, exactly like the agent-based VSRM deploys.

If you need a jumpstart though, use the integrated menu in Visual Studio: it is going to create stages, components and templates on your’s behalf!

image

Thursday 8 January 2015

Useful SQL queries for the TFS Administrator

Right, right – I know:

image

image

I would actually replace can with will, but people might think I am too harsh. Remember – the TFS databases cannot be modified by nobody but Microsoft, otherwise you won’t get support, you might experience unknown (and untested!) issues and mostly important – you would lose any upgrade path as the schemas are checked by the TFS installer.

Anyway I won’t be talking about modifying the databases, while instead I wanted to share some useful queries I found during my almost ten years experience with Team Foundation Server.

SQL Server is a deterministic system, but sometimes it doesn’t seem to be. For instance, AlwaysOn is synchronising some data after you messed up with a Team Project Collection used for testing purposes, and despite it might look stuck it is actually doing something.

The AlwaysOn Dashboard doesn’t show anything but a Synchronizing status, so how can I say so?

Run this query:

SELECT dmv_2.login_name AS Invoker,
dmv_1.session_id AS SPID,
command as 'Instruction Type',
a.text AS Query,
start_time AS 'Initiated at',
percent_complete AS Percentage,
dateadd(second,estimated_completion_time/1000, getdate()) AS ETA
FROM sys.dm_exec_requests dmv_1
CROSS APPLY sys.dm_exec_sql_text(dmv_1.sql_handle) a
INNER JOIN sys.dm_exec_sessions dmv_2
ON dmv_1.session_id = dmv_2.session_id

This is what you’ll get:

image

Excluding the line where I am the Invoker – of course – I can see all the activity at 11:08am:

  • NT AUTHORITY\SYSTEM running sp_server_diagnostics
  • The TFS and SQL service account in this testing environment running an INSERT query – that is AlwaysOn!

That query leverages SQL Server’s DMVs, and it is very handy for checking all the things happening in the Database Engine.

Another one is about Transaction Log files – what about their physical status?

SELECT Name,
database_id,
log_reuse_wait,
log_reuse_wait_desc
FROM sys.databases

Querying sys.databases can give you the status of your Transaction Log files. I needed that because I was running some extreme tests in borderline conditions, hence I had to monitor their status. Sys.databases is very handy for other information as well.

Eventually, as Grant suggests (and he is always right!), DBCC CHECKDB regularly is a must. And please, have a test server around so you can compare all the behaviours, if any.