Saturday, 26 July 2014

Tool & Action to Run Custom PowerShell Scripts in Deployment Agent – VS 2013 Release Management

Can we run a custom PowerShell script in Release Management Deployment Agent?  One way is to create a PowerShell script and add it as a resource and create a tool and an action in Release Management Inventory. This is more suitable for adding a generic tool. But if we want to run a custom PowerShell script specific to a given release template, copied to deployment machine from the build drop, can we do that? Out of the box set of tools and actions in Release Management Server do not support this. We can do this by creating a generic tool and an action.
Let me show you how to do this step by step.
In Release Management Client go to Inventory tab Tools, click on New.
001

For the execution command type “powershell” and for the arguments type
-command __ScriptToExecute__  __Arguments__
This will add two parameters in the tool “ScriptToExecute” and “Arguments”. Provide a suitable Name and a Description as well.
002

Click on Save & Close to add the new tool.
003

Go to Actions and click on New to add new action.
004

Select the tool we have created and add a new Category for Custom Actions. Fill the Name and Description.
005

Save to create the new Action.
006
 007

Let’s test our Tool and Action in action. First we need a very simple PowerShell script like below.
008

In a test release template now we can see our custom action available.
009

Fill the script name with the path and arguments(for testing purpose script copied manually to deployment machine, this can be a script downloaded to deployment machine from the build drop using an XCOPY action in the release template).
010

Save the release template and click New Release to test. This example does not use a build out put, but the action can be used with a template bound to a build drop as well, as a matter of fact it can be used with any release template.
011 

Start the release by clicking on Start.
012

Script execution succeeded.
013

Click on View Log to see the output from script.
014

To fail a script based on a condition throw an exception like below and release action will fail.



Sunday, 20 July 2014

Setup Release Management Client

This is the second step of setting up VS 2013 Release Management environment. Prerequisite for this step is Release Management Server which is described here.
Trial version of VS 2013 Release Management with update 2 can be downloaded from http://go.microsoft.com/?linkid=9843020.
Note: You cannot apply a license key for the trial to make it licensed version. Instead you have to uninstall trial and install licensed copy downloaded with MSDN or Volume License to apply license.

In the downloaded ISO run rm_Client.exe to install Release Management Client. This is a very quick install.
001

Installation is quick and smooth.

002
 003

Once lunched provide the url of the release management server. example – http://ReleaseManagmentServer:1000
Below picture shows TFS since this installation of the Release Management Client is done on tfs box.

004

This url is correct but cannot be connected by the client.

005

Check if Release Management Server app pool is running and if not start it.

 006

Try browsing to http://releasemanagemntserver:1000/ReleaseManagement

008

This could happen, if the Release Management Server is installed in TFS box with Sharepoint Foundation. To resolve this issue refer Release Management Server in TFS box with Sharepoint Foundation, the fix specified in there is below.


  • On the machine where the Release Management Server was installed with TFS and Sharepoint, start a Command Prompt. Run as Administrator but not sure this was required.
  • Navigate to C:\Windows\System32\Inetsrv
  • Enter the following command
    appcmd.exe set config -section:system.webServer/globalModules /[name='SPNativeRequestModule'].preCondition:integratedMode,bitness64

  • 009

    Browsing to http://releasemanagemntserver:1000/ReleaseManagement succeeds.

    012

    Below error occur if the user running Release Management Client is not added as a user in Release Management Server.

    013

    To resolve this issue add the user to Release Management Server, users, by clicking new on Administration tab Manage Users. (To do this log on to the Release Management Client with a user already available in release management server – example - run client as installation user of release management server).

    020

    Add the required user.

    021
     022

    Release manager is the super user role in Release Management Server.

    023

    The user should be able to connect to the Release Management Server from a remote machine using the Release Management Client.

    025
     026
     027

    We have setup a Release Management Server, and Release Management Client accessing the server from a remote machine successfully. Next step is to set up Deployment Agent(s).

    Tuesday, 8 July 2014

    Setup VS 2013 Release Management Server

    Let’s look at step by step “How to setup a VS 2013 Release Management Server”, which is the heart of VS Release Management. To understand more, the best and the official resource you must go through is VS 2013 Release Management Installation Guide.  Trial version of VS 2013 Release Management with update 2 can be downloaded from http://go.microsoft.com/?linkid=9843020.
    Note: You cannot apply a license key for the trial to make it licensed version. Instead you have to uninstall trial and install licensed copy downloaded with MSDN or Volume License to apply license.
    Prerequisites for VS 2013 RM (Release Management) Server is below as per VS 2013 Release Management Installation Guide.

    Processor: 1 GHz Pentium processor or equivalent (Minimum); 2GHz Pentium processor or equivalent (Recommended). 
    RAM: 1024 MB (Minimum); 2048 MB (Recommended). 
    Hard Disk: On a clean machine, up to 2.2 GB of available space may be required. This is due to the dependency on .NET. Database can grow up to 1 GB per year (could be as low as 10 MB - depending on usage) 
    Display: 1024 x 768 high color, 16-bit colors (Minimum); 1280 x 1024 high color, 32-bit (Recommended). 
    Supported platform:  • Windows Server 2008 R2 SP1 • Windows Server 2012 • Windows Server 2012 R2 
    Database requirements: Microsoft SQL Server 2008 or 2008 R2 or 2012

    The installing user (user who is setting up the Release Management Server) requires local administrator rights and sysadmin rights on the SQL Server (SQL Server that is going to have Release Management Server database). I will be using TFS Admin as the installation user of the RM Server since I am setting up the RM Server  in the same box  where the TFS is installed. Ideally the RM Server should be set up in a different clean computer and TFS is not mandatory to do release panning and execution with VS 2013 Release Management. (TFS is optional, but can be integrated really well with VS 2013 RM to automate from builds to release).

    As the first step we need to setup an account, to be used as the service account for the Release Management Server.

    001

    002

    Run the downloaded rm_server.exe to launch the setup.

    003
    004

    Accept license agreement and click “Install”.

    005

    Once install launch to configure.

    006
     007
     008

    In the configuration window specify the release management service account and SQL Server to create the RM database.

    009 

    Apply settings, you will encounter the first error in RM Server configuration, and fortunately it is a descriptive error “The account specified is not a member of the local administrators group”.

    010

    Add the RM Service account to local administrators group to resolve this issue.

    011

    Now the configuration proceeds.

    012


    The next error which might occur if the server resources are limited (This demo environment has only one cpu core and 4GB RAM while running SQL, SharePoint Foundation2013, TFS in same box). The error message is not very helpful.

    013

    Log file shows failing when getting RM site state, looks like some time out.

    014

    Increase resources in the machine and retry the configuration, now fails with application pool already exists (I believe MSFT will make this experience of retry configuration, better in a future release).

    016

    Manually deleting app pool and any web sites created for Release Management will resolve the issue.

    015

    Retry configuration succeeds.

    017

    To confirm the success state of configuration verify below check list.
    1. Release Management database is created  in SQL Server.
    018

    2. RM Service account mapped to RM database dbo schema.
    019
    3. Release Management app pool is created with identity RM Service account, and RM web site is created as below.

    020 
    4. Release Management Monitor windows service is running with RM Service account.

    021

    Now we have a VS 2013 Release Management Server up and running. Next post of series VS Release Management, I will explain “How to setup and configure Release Management Client”.

    Sunday, 6 July 2014

    Visual Studio Release Management

    Do we need to manage software releases/deployments in a well planned methodology? Do we need to track the details of the releases/deployments? Do we need to have a proper rollback strategy if something goes wrong in a deployment to production? I could keep asking more and more questions like this related to the software release management, and always the answer would be “YES”.
    So what are our options, in terms of Microsoft ALM set of tools. TFS Lab environments can be used, but can we use it for production releases automation? Yes, if the client is willing to provide trusted access to production environment, via TFS Lab environments. But in most cases client would not like this. To add more pain to this Lab environments deployments would over utilize the build servers, with long running deployments. The solution for all this pain is addressed well in, new Visual Studio 2013 Release Management.
    First we need to understand “Why” we need to manage releases. This post in NorthWest Cadence provides great insight.
    There are three major components in VS 2013 Release Management.
    1. Release Management Server.
    Set of windows and web services that act as the core part of the release management. There is a portal providing approval capability to the release check points, without having to install Release Management Client or Visual Studio.
    2. Release Management Client.
    Windows Presentation Foundation (WPF) application provide the interface to manage the releases and configurations of release management.
    3. Deployment Agent
    Resides in target servers in the environment and performs the deployment actions such as installing, uninstalling, configuration etc. of software components.
    Each of above performs its own duty, and resides in different computers. Together they make deployment automation a possibility with all the visibility and traceability expected in proper Application Lifecycle Management process.
    The following diagram extracted from VS 2013 Release Management Installation Guide provides overview of “How it works”.

    000

    Even though above picture shows TFS, it is not mandatory to have TFS for VS Release Management to work. If the TFS is available can be tightly integrated with it. If not it could obtain payload for the deployment from any accessible drop locations (UNC path). This means the deployment could be even something not developed with .Net .
    Below diagram from VS 2013 Release Management Installation Guide  explains communication between components of release management.

    0000

    The most important thing here is the Deployment Agent is downloading the components for deployment as a pull request. Nothing is pushed from Release Management Server to Deployment Agent. This enables the possibility of Release Management Server not requiring access to Production environments. Deployment Agent notify Release Management Server it’s availability via heartbeat.

    Let’s start our journey to explore Visual Studio Release Management by setting up an environment step by step, with my series of blog posts in next few weeks.
    1. Setup Release Management Server.
    2. Setup Release Management Client.
    3. Setup Deployment Agent.
    4. Configure SMTP.
    5. Configure TFS Connection
    6. Setup Stage Types.
    7. Setup Servers & Environments.
    8. Setup Release Path.
    9. Demo Release Template - Part 1.
    10. Demo Release Template - Part 2.

    Saturday, 5 July 2014

    Awesome Improvements in Visual Studio Online

    VS Online is added with few great improvements. My guess these will be available with TFS 2013.3 for on premises TFS. Still had no chance to have a look at 2013.3 RC :( .

    Hiding work in progress on the backlog
    Full Screen on the backlog and boards
    Move to position on the backlog
    REST APIs and service hook support for pull requests

    Have a look at release note of VS online for more detalis

    Popular Posts