Code Metrics Trend in Jenkins with VS Code Metrics Powertool VS2013



Visual Studio Code Metrics Powertool for Visual Studio 2013:

Jenkins plugin Visual Studio Code Metrics Plugin:

First you need to download and install Visual Studio Metrics Power tool which will install metrics.exe in the following location: c:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\metrics.exe.

In Jenkins instance install Visual Studio Code Metrics plugin which will enable you new options that have to be configured.

Navigate to Manage Jenkins >  Configure System > VS Code Metrics PowerTool


Go to build job.

Add a new build step and configure it as follows:

Add a new post-build step and configure it as follows:


After you run the build job, you will start to get results.

On the job results page

By accessing Code Metrics option from left side you can go deep into details

Host your ASP.NET application in AppHarbor


AppHarbor is a .NET platform as a Service hosted in cloud in other words you can build your .NET solutions in cloud. Prices start from free. My example will use all free features, but if you want to go pro and keep your continuous deployment infrastructure in cloud, AppHarbor can be a good choice.

In terms of integration with code repositories, AppHarbor supports Bitbucket, Codeplex and GitHub. It’s time to learn Git, so I will use a GitHub repository.

AppHarbor allows you to add multiple add-ons into your app, starting from free but also subscriptions. Add-ons categories are: databases (including MSSQL), email, monitoring, queue (message queues).

I will be using a blank ASP.NET MVC application. Source code can be found at

Basic app deployment

Create a new application in AppHarbor and integrate it with GitHub repository. Go to Settings, disable precompilation, choose the branch you want to build (I use master branch). In few minutes build process should be done, click Deploy (besides the Build) and then wait for the app to load. Check the recording below to see the steps in action.
Each commit in the repository will trigger an automatic build and deploy in AppHarbor. Cool. 


Run unit tests

AppHarbor at the moment of writing this post, offer support for the following testing frameworks:

  • MbUnit ( –
  • MSTest
  • NUnit (, – and –
  • (1.1.0 – 1.9.1)
  • MSpec ( and

Next step is to add XUnit support to app and create few dummy tests. Run Install-Package xunit for DemoApp and create tests to see if AppHarbor will really execute them. Commit is detected by AppHarbor, build process starts and after that tests are run.


SQL Server add-on

AppHarbor allows you to add SQL Server support for your app. You can get a 20 MB database for free. After you install this add-on, click on Go to SQL Server for connection details. Those details can be used in your app for running scripts or add mock data.





Scripting TFS Command line for get latest version, check-out, check-in, new branch


Getting latest version of you code from TFS is not so easy, especially if you compare with Git. In some cases you need to be able to perform get latest command, check-ins, check-outs from a custom script and not from Jenkins plugins. Finding the right sequence of TF commands and the right combination of parameters can be very hard.

Note: For TFS Online (http://***** you need to use Team Explorer Everywhere ( because the classic tf.exe does not support passing credentials via command line.

For on-premise TFS instance, WindowsLiveId must have the format of domain\username.

Get latest version from TFS Online or On-Premise

tf workspace
-new CodeWorkspace;WindowsLiveId

tf workfold
-map $/TFS-PATH-TO-PROJECT .                  <— you need to use that dot (.)

tf get

tf workfold
-unmap .                                                              <— you need to use that dot (.)

tf workspace
/delete CodeWorkspace


tf checkout $/TFS-PATH


tf checkin $/TFS-PATH

Create new branch

tf branch $/existing-branch $/new-branch

Jenkins and TFS Online

This post is about getting the latest code from TFS hosted in cloud not on premise. It’s applicable to a TFVS repository not to a Git repository.

Getting the latest version from VisualStudio.COM (aka. Visual Studio Online) doesn’t work with the traditional TF.EXE. Reason for that is that tf.exe doesn’t support VSO login dialog. Which makes impossible to use your Windows ID credentials, unless they are already cached in your Team Explorer or Visual Studio.

This can be done at this point using Team Explorer Everywhere for Team Foundation Server. For this example I’m using version TEE-CLC-12.0.2.

Team Explorer Everywhere

Download this package into a folder on your machine.  Once you are done, you will see tf.cmd which is the replacement for tf.exe .

Add this location to your environment Path under System variables section.


Configure your Jenkins instance

As a prerequisite, you need to have already a Jenkins instance, up and running.

Go to Manage Jenkins > Manage Plugins. Switch to Available tab and search and install the following two plugins:

Configure Team Foundation Server Plug-in

Team Foundation Server plugin is using by default tf.exe. We need to change this configuration to point the location where you’ve unpacked Team Explorer Everywhere.

Go to Manage Jenkins > Configure System and scroll down until you find Team Foundation Server section. Update the path there.


Configure MSBuild plugin

This plugin is responsible for calling msbuild.exe.

Go to Manage Jenkins > Configure System and scroll down until you find MSBuild section.


Create Jenkins project

Navigate to Jenkins home page, choose New Item, pick Freestyle project and provide the Item name field.


Important: Running TFEE for the first time will ask you to accept the End User License Agreement. This command must be run from the context of your workspace per this project. Just before setting up the source control settings we need to run: tf eula –accept.


Accepting TF eula

Under the Build section and a new Execute Windows batch step.


Note: If you’ve change the environment Path property, you need to restart the Jenkins service. If you don’t, will continue to say that it doesn’t know about tf.cmd.

Save the project and run the job. You should get a result in console saying that you’ve accepted the EULA.

You can now remove previous added step, because EULA is now accepted.

Configure Source Control Management

Scrolling down in the configuration page for this project, you will get to Source Code Management section.

VERY IMPORTANT: For login name you MUST use Window Live ID, but you MUST have also alternate credentials activated – don’t use them.

Login name:

User password: yourliveidpassword


At this point everything should work as expected.


Adding the build step

Go back to the projects/job list and select TFVS demo. Choose to configure this project. Scroll to the Build section and add a new step called “Build a Visual Studio project or solution using MSBuild”.


Depending on how your file/directory structure is, you have to provide the solution path relative to workspace.




And the result is:


Feel free to contact me. I’m eager to know if this helped you or if your are having troubles in applying this steps.

Must known Git commands

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency –

Git has all the attributes of a distributed version control systems, it works in a on machine level but also in a collaborative way which is accessible for the network.

Suggested reading:

Command Description
git config –global “YOUR_NAME” Your name will be displayed in the history.
git config –global “YOUR_EMAIL” Your email will be displayed in the history.
git init <project name> Creates a local Git project ready for adding and committing file, including history but a local level.
git clone <path to git repository> Clone a remote git repository.
git remote List remote connection to other repos, using the context directory
git remote -v List remote connection to other repos, using the context directory, including URL
git remote add <name> <url> Create a new connection with <name> to a remote repo hosted at <url>
git remote rm <name> Remove remote connection with <name>
git remote rename <old-name> <new-name> Rename a connection
git fetch <remote> Fetch all of the branches from the repository identified by remote name. Resulting commits are stored as remote branches instead of local branches.
git fetch <remote> <branch> Fetch specified branch
git branch -r List all remote branches
git add . Add all the new files in the local repository – not yet committed in the local repository.
git commit -m “commit message” Commit all new additions and changed files in the local repository.
git push <remote> <branch>
git push -u origin <branch>
Push the specified <branch> to <remote>. In a git context the most used is the second command.
git status
git status –s
Shows what’s going on with the working directory. Added, modified, deleted. Adding –s will show the results in a concisely mode.
git diff Shows diffs of the affected files.
git branch Shows all the braches .
git checkout –b <new-branch> Create a a new-branch and switch to that new-branch.
git checkout <existing-branch> Switch to existing-branch.
git merge <branch-name> Merge branch-name into the context branch. See context branch using git branch command.
git log Display entire commit history.
git log –n 3 Show only last 3 commits.
git log  –oneline History is displayed in a single line.
git log –stat Include in history affected files.
git log –p Shows commit history in a detailed view.
git log <file> Shows commit history for specified file.
git log –author=”<pattern>” Shows commit history for specified author.
git revert <commit> Revert to the specified commit. List of commits can be viewed using git log.
git clean Remove untracked files from working directory
git clean -n Remove untracked files without actually removing files
git clean –f <path> Remove untracked files from specified path
git clean –df Remove untracked files and directories from the current directory
git clean -xf Remove untracked files from the current directory and any files that Git usually ignores
git reset –hard
git clean -f
Running both of them will make your working directory match the most recent commit, giving you a clean slate to work with

Why Agile ?

A deep overview, philosophy and different agile development methods can be found on Wiki.

In my opinion the benefits of Agile are:

  • It’s a methodology that’s deliver value to customer, faster.
  • Manage rapidly the change of priorities (Nowadays there is a high market pressures and technology advances. We need to be responsive to change and manage that)
  • Mitigate the risk by continually sharing your progress with your customer in order to validate what you are building is really what they want – DAY by DAY with your customer
  • Reduces uncertainty, remove waste
  • Short time-to-market
  • Increase revenue by focusing on customer value
    • Agile produces the high business value in the shortest time by developing products in iterative incremental manner.
    • Each sprint (2-4 weeks) evolves requirements definition, product design, coding and testing.
    • The result after each sprint is a potentially releasable increment. Each other sprint will evolve the product.
  • Improved quality
    • fewer defects into production (testing always not only at the end of the cycle)
  • Start to get feedback from production
  • Sprint retrospectives – an organized way for improvement

Coaching and Mentoring

Both of them help an individual to grow and develop. The difference it’s in approach and results. A well known comparison  describe them:




Source of Relationship




Personal and Professional

Professional – Personal only if relates to professional


Related to life in general

Specific to work requirements

Performance measurement





Improved performance

Mentoring is something more personal, it’s happing when another individual accepts to do.

  • Rewards come from the relationship between the mentor and mentee
  • Performance measurement won’t exist or will be very informal

Coaching relationship is part of your job or position.

  • Goals related to your job performance
  • Goals should be specific, measurable since you will be judged by them
  • Goals should be formal, agreed-upon, clear, and documented

Reasons for poor performance

  • Lack of required capabilities
  • The job isn’t challenging enough
  • They feel aren’t appreciated
  • They feel they’ve been overlooked in some way
  • They don’t get along with their colleagues
  • They have personal problems
  • They’ve developed an attitude
  • They lack the motivation
  • The job isn’t right for them

Agile and the Seven Deadly Sins of Project Managing


All boats leak.  The question isn’t “is this perfect?”, the question is “will this get me there?” The real goal is to go somewhere.

My notes based on Mike Cohn presentation.


  • fix all dimensions of the project will induce overtime, cut quality
  • add people – risky
  • cut business but that’s could be a problem with management
  • FIX: timeboxes, fix iteration length but variable number of iterations, predictability (velocity)


  • to much/more features
  • FIX: priority order, see progress, working at a sustainable pace (see picture)


  • loosing focus on doing high quality work, not doing testing/unittests
  • FIX: simple design, automate testing, TDD, CI – find NOW if something is broke, pair programming, refactoring


  • obscuring quality, progress or other attribute
  • for quality: not knowing bugs count, done vs not done
  • schedule: burndown chart
  • FIX: show real progress of the team


  • we believe that we know everything to build the product => lack of stakeholders and user involvement
  • not learn anymore
  • FIX: retrospective, standups – get feedback, US – work closely with users&customer


  • misuse of resources (time, motivation, losses of creativity)
  • FIX: timebox, daily standups (small sleep – focus on things),


  • teams who don’t see the big picture
  • individuals who work only within their roles
  • FIX: release plans, cross functional teams