The basic reason that my build and release solutions work well and add value is simply because I write scripts to do everything and I work very hard to eliminate any possible human error. Effective Release Management is all about taking manual (error prone) procedures and making certain that there is no possible room for error. I call this "Bob-proofing" your scripts. I always setup my scripts so that they explain what they are about to do and then ask for verification before proceeding. I also log every step so that you know exactly what you did and when you did it.
CM/RM is repeatable and traceable Good Release Management is repeatable and traceable. I always tell people that I might make a mistake, but I will always be able to show them exactly what I did so that we have complete traceability. Now I am not a great coder but I always automate my procedures in a scripting language (e.g. Unix K-shell, bourne shell, Windows Bat files and sometimes the fancy stuff in Perl). There are many people - well almost any programmer - who can code better than me, but I add value by making certain that my release management scripts completely foolproof the entire build and release management process. I call this the "ergonomics" of release management. Recently, I came across a scripting language from Microsoft that has really impressed me as being a huge step forward for Windows based build and release management. The language is called Powershell.
Powershell for success The version of Powershell that I have been learning is called Windows PowerShell V2 Community Technology Preview 2 (CTP2) ( and is different than it's predecessors known as Windows PowerShell 1.0 and Windows PowerShell V2 CTP) The download page that I used was located here http://www.microsoft.com/downloads and then I specified Powershell V2 CTP2, which is the Community Technology Preview 2 (CTP2) of Powershell Version 2. Note that it is called "Technology Preview" because it is not viewed as being ready for all Production environments. My first Powershell script I used notepad to create my first Powershell script

|
#myProgram.ps1 - First Powershell script for CM Crossroads article #Bob Aiello February 1st 2009
function pause ($myMessage) {
Write-Host -NoNewLine $myMessage $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") Write-Host ""
}
# The "say" command reminds me of my old days writing Rexx ! function say ($myMessage) {
Write-Host $myMessage
} ## The program really starts here ##
echo "You can use bat file commands like echo or"
pause("press enter and I will continue");
say "Use the fancy commands in Powershell like this one"
|
Which gave me the following output 
Powershell does require codesigning In order to run my test script on Vista I had to work around Powershell's built-in requirement for code signing (in the future I will write an article on how to use code-signing effectively since I believe that it is a critical function that you should be using for all of your build and release management scripts).
For this example (and since I am using Vista) I ran Powershell as an administrator by right clicking on the Windows Powershell V2 icon and selecting "Run as administrator".
|
Here is how I turned off codesigning (again I only did for this example...
PS C:\Users\adm> Get-ExecutionPolicy Restricted
PS C:\Users\adm> Set-ExecutionPolicy Unrestricted
PS C:\Users\adm> Get-ExecutionPolicy Unrestricted
|
Making your scripts fail-safe There are a lot of built in objects that make Powershell programming pretty slick. Here is a simple way to make sure that your scripts don't get started by accident - potentially blowing up Production!
|
#ProductionPromotion.ps1 - Making your scripts failsafe #Bob Aiello February 1st 2009
$title = "Promote to Production" $message = "Are you ready to promote to production?"
$yes = New-object System.Management.Automation.Host.ChoiceDescription "&Yes", `"Move those files in!"
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "No don't proceed yet!"
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
#IMPORTANT - note that the "1" below makes the default "No" and thus fail-safe! $ans = $host.ui.PromptForChoice($title, $message, $options, 1)
switch ($ans) {
0 {"You selected Yes."} 1 {"You selected No."; exit}
}
echo "we got here so you must have said YES!"
|
Here is my first run 
I could not remember my choices so I put in a "?" and got back my choices for Yes or No - pretty cool. Then I ran it again and selected "No"

Notice that if I entered No or simply did not answer I set the default to no which makes this script failsafe.
Of course when I am ready to go forward I can select Yes as well.

Powershell is a cool way to automate your build and release scripts So Powershell is indeed a great way to automate your build and release management scripts on the windows platform. I am working on a lot of C#, .net and SQL Server releases these days which makes Powershell the scripting language of choice for me. Please send me your own tips on how to automate build and release management and, of course, remember to make all of your promotion scripts failsafe since Effective CM and RM practices means avoiding any possibility of mistakes!
Resources that I used for this article There were a number of good books and websites that I found for learning Powershell. My favorite is Apress's Pro Windows PowerShell by Hristo Deshev, but I would have been lost without my many Wrox books on .net, C#, SQL Server and Powershell. I also found a number of good resources on the Microsoft technet and a number of great websites/blogs (e.g. http://powershellcommunity.org). Feel free to drop me a note if you need the ISBN numbers for the books that I have been using. Your turn! I always love hearing from other technology professionals on how they approach their own CM and RM best practices. Please drop me a line and share what works and what doesn't in your own environment!
Bob Aiello is the Editor-in-Chief for CM Crossroads and a Software Engineer specializing in Software Process Improvement including Software Configuration and Release Management. Mr. Aiello has over 25 years experience as a technical manager in several top NYC Financial Services firms where he had had company-wide responsibility for CM, often providing hands-on technical support for enterprise Source Code Management tools, SOX/Cobit compliance, build engineering, continuous integration and automated application deployment. Bob is the Vice Chair of the IEEE 828 Standards working group (CM Planning) and was recently elected to the IEEE Software and Systems Engineering Standards Committee (S2ESC) Management Board. He is a long standing member of the Steering Committee of the NYC Software Process Improvement Network (CitySPIN), where he serves as the chair of the CM SIG. Mr. Aiello holds a Masters in Industrial Psychology from NYU and a B.S. in Computer Science and Math from Hofstra University. You may contact Mr. Aiello at raiello@acm.org or link with him at http://www.linkedin.com/in/bobaiello
Trackback(0)
Comments 
Write comment
 |