Showing posts with label SCM. Show all posts
Showing posts with label SCM. Show all posts

February 8, 2014

SCM - Branching Guidelines for Agile Development

This article discusses the principles and policies around the branching guideliness with examples for Agile Software Development.

Branch Policy

Independent of the tool used for source control management, Mainline or Trunk will be the stable main source tree, ready for release at any time.

Branching as part of source control management is intended for code-separation or code-isolation and it becomes inevitable under the following scenarios
  •  Release Branch for Major or Minor Releases
  •  Maintenance Branch for Patches / Hotfixes
  •  Feature Branch in case of Feature Driven Development (FDD)
  •  Team Branch in case of Agile Development or FDD where you branch to isolate sub-teams. 
Each team will have a development branch where they will do the day to day work.

 

Each team can promote or merge their finished stories to the mainline branch.
 
When all storied or features are done for a release, then create label (TFS) or TAG in SVN with the release name.
 
Ideally we would create the following branches for efficient code-isolation



  • Trunk or Mainline– Stable Code line
  • Dev – Feature or Team branch under development
  • Release –  From which the code is deployed to production
    • Maitenance - Fixes for code-breaks, if any, in production. This will be usually under the corresponding release branch.

    Branch Owner
    Each branch will have an appointed branch owner who will be responsible for enforcing branch policy and will be responsible for merging and resolving conflicts.
     
     
    Trunk or Mainline Branch

    The Trunk and Mainline branch is from where the releases are made. This line should never break otherwise the whole idea of having Team or Feature specific branch will go in vain.

    Trunk or Mainline Policy

     The name of the Branch will be either Trunk or Mainline

     1.    Can be released at any time
    At any moment, the product owner can decide that we should make a new production release directly from the tip of the mainline. A release branch can be created to proceed with the production release.
    2.    Want to release ASAP          We shouldn't check in or merge a finished story to Trunk unless it has to go live (or at  least wouldn't mind if it goes live).  

    Team Branches

    Team branch is for checking in stories which are in progress. This branch is also used to run integration tests before checking in stories to the Trunk and can be used by the Agile or Attached QA to verify the completed stories before it goes to Trunk. The name of the branch will be  Team_A, Team_B etc.

    Team Branch Policy
        1.    Code compiles & builds.
    2.    All unit tests pass.

    The terms Promote and Rebase are tied to the source control tools like Seapine Surround and TFS but where as SVN and Git uses Merge (upward or downward) extensively.

    Rebasing
    This is the process of propagating changes from the Trunk to the team development branches. This has to done often, minimum once a day, preferably when the developer starts his day.

    Rebasing Policy
    1.    Every day when a team gets to work, someone (generally the branch owner) in the team is responsible for merging the latest version from Trunk to the team dev branch.
    2.    If the team discovers a code conflict it has to be resolved it immediately - that's top priority!
    3.    If the team needs help from other teams or whoever wrote the code that conflicts the team has to go fetch them and work together to sort it out.
    4.    The important thing is that team is responsible for getting the problem sorted out, and that we need to sort it out on the team dev branch and not on the Trunk.
    5.    Conflict should be resolved in the branch which is least stable.
    6.    Rebasing can be done as frequently as possible and not necessarily once a day. But the minimum should be once a day.
     
     


     
     
     
     
     
     
     
     
    Promoting
     
    The stories that are completed in the team dev branch and ready for production is merged upwards to the Trunk and is termed as Promoting.
     
    Promoting Policy
     
    1.    When stories are completed and ready to go to production, they will have to be promoted to the Trunk branch from the Team branch.
    2.    Ideally there should be no selective promotion which essentially means that the complete changes in Team Dev branch should be promoted and after the promotion is done the Team Dev branch and the Trunk should be equal.
    3.    "Ready to Promote" is the Team's decision when they feel that the stories are ready.
    4.    The promotion has to be done by the branch owner or under his or her supervision.
    5.    The promotion should be done as and when a story is completed and should not be deferred to end of the sprint.
    6.    Just before the promotion is done a rebase should be done to identify and relsove the conflict, if any.
     

    Release Branch

    Release branch (say Release 1.1.0 in the below image) is created when the product is ready for release.



    After the release, based on the Product Road Map, the Product Owner may choose to release Service Pack Release or work on the bug fixes for critical issues, if any, reported by the customer. In the above image, any issues reported on 1.1.0 will be fixed in that branch and release to customer. After releasing the HotFix 1 for the patch, Release 1.1.1 branch is created. In some cases, if more than 1 HotFix needs to be worked on independently at the sametime, the developer can create HotFix specific branch (similar to Team Dev branch) and merge it to the respective release branch before taking it to production. 
    

    March 17, 2013

    Silent install / uninstall command for Slik SVN 1.7.8


    The following post discusses about the Silent installation / uninstallation command for Slik SVN 1.7.8m - 64-bit installer and the same applies to 32-bit installer as well.

    Installation:
                   msiexec /i "Slik-Subversion-1.7.8-x64.msi" /qn /norestart INSTALLLOCATION="D:\Software\SlikSVN" /l* "svninstall.log"
                          /qa -> optional parameter to run the installer in silent mode
                            INSTALLLOCATION -> Custom Installation directory
                            /l* "svninstall.log" -> optional parameter for logging the installation to svninstall.log

    Uninstallation:              
    ·         Silent Uninstall command with Product Code:
                    msiexec /x {D0BD7396-3187-48FE-8327-C27385275D18}

    ·         Silent Uninstall command with installer name:
                    msiexec /x "Slik-Subversion-1.7.8-x64.msi"

     
    For locked down environments like Vista, Windows 7 & Windows Server 2008 (when UAC is turned ON), do the following

    ·         Launch the command prompt with elevated privileges (i.e. Right Click cmd.exe and say “Run as administrator”), otherwise the installer will fail.

    ·         If you get the following error message while running msiexec from the command prompt, append “C:\Windows\System32” to the PATH variable
                                    'msiexec' is not recognized as an internal or external command,
                                    operable program or batch file.

    February 4, 2013

    Ant: Did you know that using arg 'value' instead of arg 'line' will have an impact?

    We heavily use Ant scripts for Build automation and it came as a big surprise that using arg 'value' instead of arg 'line' will have an impact. This article will focus on the problem statement that had issues and the Solution for the same.

    Problem Statement:

    There were two issues as detailed below while creating the Tags the Ant Script.
     
    1) When the SVN authentication credentials are saved

    -->The below script is creating a directory with the time stamp but its including the username and password also in the directory name (e.g  "20130130_044807 --username testuser --password testpass")
    -->We tried with many options but it's still taking the username and password in the directory name.
    --> Tagging is working properly.
    <?xml version="1.0"?>
    <project name="samplescript" default="TagSource">
    <property name="SVN_UNAME" value="testuser"/>
    <property name="SVN_PWD" value="testpass"/>
    <property name="SVN_LOGIN" value="--username ${SVN_UNAME} --password ${SVN_PWD}"/>
    <property name="SVN_TAG_MSSG" value="tagging"/>
    <tstamp>
                    <format property="TODAY" pattern="yyyyMMdd"/>
     </tstamp>                        
                       <tstamp>
                          <format property="NOW" pattern="HHmmss"/>
      </tstamp>  
     <property name="svn_dir" value="${TODAY}_${NOW}"/>
     <echo> ${svn_dir} </echo>
     <property name="SVN_URL" value="http://url/trunk/${svn_dir}"/
     <echo> ${SVN_URL} </echo>
    <target name="TagSource" description="Creating a directory and tagging the working copy" >
       <exec executable="svn">
                    <arg value="mkdir"/>
                    <arg value="${SVN_URL} --username ${SVN_UNAME} --password ${SVN_PWD} " />
                    <arg value="-m Creating_dir" />
       </exec>               
       <exec executable="svn">
                    <arg value="copy"/>
                    <arg value="D:\backup\SQL\xsl" />
                    <arg value="${SVN_URL} --username ${SVN_UNAME} --password ${SVN_PWD} " />
                    <arg value="-m tagging" />
       </exec>
    </target
    </project>
    2) When the SVN authentication credentials are not saved:
    -->The same above script is failing with the below error:
               TagSource:
         [exec] Authentication realm: <http://url:80> Subversion Repo 
    The main issue here is It's not considering the username and password provided in the script.
     
    Solution:
    Instead of the following statement,
    < arg value="${SVN_URL} --username ${SVN_UNAME} --password ${SVN_PWD} " />

    use

    < arg line="${SVN_URL} --username ${SVN_UNAME} --password ${SVN_PWD} " />

    arg value treats entire value as single command separated by space.
    arg line will consider this as separate command delimited by space.

    Thanks to Mayur Bhatt for the solution.

    September 7, 2012

    TFS - Moving from one Hardware to another

    This article focuses on moving an instance of Visual Studio Team Foundation Server from one hardware configuration to another, which is termed as "Restoration based move" in TFS.
    A key point here is that the Restoration-based move can be used only when your database and application tier are in the same machine.
    Requirements to perform Restoration-based move.
    ·         Machine must be Windows Server 2008 R2 with enough space for restoring the databases.
    ·         Machine should have the exact same configuration what old machine has.
    ·         You must be the user belongs to administrator group in the server.
    ·         You must be added in the SQL Server login group and should be given the following permissions.
    o    Dbcreator
    o    Public
    o    Security admin
    o    Server admin and
    o    Sys admin
    Steps to be followed.
    Assume that the machine names are TFS01 (Old machine name) and TFS02 (New machine name)
    Make sure that the current user has sysadmin as well as Admin privilege in the system as well as TFS
             I.            Taking the backups from TFS01.
    a.        First we need to take the full backups of all the databases
                                                                   i.      Tfs_Configuration
                                                                  ii.      Default Collection
                                                                iii.      Tfs_CollectionOne
                                                                  v.      Tfs_CollectionTwo and etc
                    We have to take up the DefaultCollection database backup also. Because Tfs_Configuration maintains the settings of Default Collection and unique collection id of Default collection. 

           II.            Prepare the new machine TFS02.Install all the required software with only one user.
    a.        Get an ESX Server Image or Physical machine with the following configuration
                                                                   i.      OS - Windows 2008 R2
                                                                  ii.      IIS should be installed
                                                                iii.      Minimum 150GB HDD and subjected to vary based on the TFS Backup Database. Allocate 60GB for C Drive, which will have all software installations. D drive can be used to store database. So it can be 90GB initially and increased if the restoration Database size is Huge.

    b.       Install SQL Server 2008 R2
                                                                   i.      You will get a prompt to add .Net Framework to core role, if it is not already installed. Click OK.
                                                                  ii.      Support Setup Rules should succeed
                                                                iii.      Setup Role -> Go with default “SQL Server Feature Installation”
                                                                iv.      Feature Selection – Select All
                                                                  v.      Installation Configuration -> Default Instance
                                                                vi.      Disc Space Requirement -> Click Next
                                                               vii.      Server Configuration -> Select Account Name as Network Service for the following four service
    1.    SQL Server Agent
    2.    SQL Server Database Engine
    3.    SQL Server Analysis Services
    4.    SQL Server Reporting Services
    And leave other services account name as default.
                                                             viii.      Databse Engine Configuration -> Select Mixed Mode and enter password, add the current user and required domain users.
                                                                ix.      Analyssis Service Configuration -> add current user and required users
                                                                  x.      Reporting Services Configuration -> Install the native mode default configuration
                                                                xi.      Continue with the installation.

    c.        Install Microsoft Team foundation server 2010. Install only with the current user who is performing the restoration.
                                                                   i.      Copy TFS 2010 DVD content from en_visual_studio_team_explorer_2010_x86_dvd_509698.iso to the TFS Server and extract it using WinRAR
                                                                  ii.      Run Setup.exe from .\TFS-x64 folder.
                                                                iii.      Select “Team Foundation Server” in the feature selection dialog and click Next, It installs the following
    1.    VC 9.0 Runtime (x86)
    2.    VC 9.0 Runtime (x64)
    3.    VC 10.0 Runtime (x86)
    4.    VC 10.0 Runtime (x64)
    5.    Microsoft .Net Framework 4.0
    6.    .Net Framework 4 Multi-Targeting Pack
    7.    Microsoft Team Foundation Server 2010
                                                                iv.      It asks for reboot after Microsoft .Net Framework 4.0 installation. The installer resumes after restart to install .Net Framework 4 Multi-Targeting Pack and Microsoft Team Foundation Server 2010.
                                                                  v.      Continue with Configure after TFS installation.
                                                                vi.      Start Wizard from the configuration center.
                                                               vii.      Enter <domain>\TFSService and use the correct password for Account details and test. Then Click Next
                                                             viii.      Readiness checks validate that your system is ready to Configure.
                                                                ix.      If IIS is not installed then you will get the following message

    Warning
    [ System Checks ] None : VFIREWALL (System Checks\Root\Firewall)
    Information
    [ Application Tier ] Service will be installed for you: IIS
    Information
    [ Application Tier ] Windows Authentication has not been configured in Internet Information Services (IIS). If you continue, it will be configured for you.

    d.       Configuration takes few minutes, which will install IIS as well.
    e.        Change the Visual Studio Team Foundation Background Job Agent logon account to <domain>\TFSService and use the correct password.
         III.            Stop the TFS Services using the Command (use RunAsAdministrator in Win 2k8 R2). C:\Program Files\Microsoft Team Foundation Server 2010\Tools\TfsServiceContrlo.exe QUIESCE
         IV.            Restoring the databases.To restore the database the user should have the same permissions as in the above requirements.
    Restore all the databases Tfs_CollectionOne, Tfs_CollectionTwo, Tfs_DefaultCollection and Tfs_Configuration and etc.
    [If the Tfs_DefaultCollection backup is not available, MSSQL Management Studio and run the following query 
    BACKUP DATABASE Tfs_DefaultCollection
    TO DISK='<some path>\Tfs_DefaultCollection.bak'
       Use master]
    For the existing database, right click on the DB Name and select Tasks -> Restore and Select Overwrite under Options.
    For the new databases, right click on the Database and select Restore Database.
           V.            Prepare the SQL Server to host the databases for Team Foundation Server.
    Log on to the server, open a Command Prompt window, and then change directories to Drive:\%programfiles%\ Microsoft Team Foundation Server 2010\Tools.
    Type the following command, where ServerName is the name of the instance of SQL Server that hosts the databases for Team Foundation Server, in either ServerName or ServerName\InstanceName format:
    TFSConfig PrepSQL /SQLInstance:ServerName
    [Note: You will get the following message :
    Logging sent to file C:\ProgramData\Microsoft\Team Foundation\Server Configuration\Logs\CFG_CFG_AT_0927_085559.log
    Command: prepSql
    TfsConfig - Team Foundation Server Configuration Tool
    Copyright (c) Microsoft Corporation. All rights reserved.
    SQL Instance ‘
    ServerName’ successfully prepared.]
         VI.            Redirect Team Foundation Server to its Databases. We must have to redirect our Team Foundation Service to our Databases if any of the conditions are true.
    a.        The TFS_Analysis or the TFS_Warehouse database is hosted on a different server from TFS_Configuration.
    b.       You are using a named instance to host your databases.
    c.        You have one or more collection databases hosted on a different server from the configuration database.

    Run the following command.
    TFSConfig RemapDBs DatabaseName:ServerName;TFS_Configuration /SQLInstances:ServerName,ServerName2/AnalysisInstance:ServerName2/AnalysisDatabaseName:DatabaseName
    Replace the ServerName with the new TFS server name.(ie TFS2).
    For us we can run the command as follows.
    TFSConfig RemapDBs DatabaseName:TFS2;TFS_Configuration /SQLInstances:TFS2
    This will do all remapping to the Team Foundation Server.
    (Note: This command also we have run the from the elevated command prompt.)

       VII.            Change the Ownership of the Moved Databases.We must have to change the ownership of the Moved Databases. For that we need to run TFSConfig Accounts ResetOwner Command. Before running we need to make sure that ,
    a.        must be appropriate user in the system
    b.       use the same account which the TFS is installed and configured
    c.        Must be the member of the TFS administrator group.
    d.       And must be the member of sysadmin in SQL Server.
    Following is the command we have run with elevated command prompt and change the directory to c:\Program Files\Microsoft Team Foundation Server 2010\Tools.
    TFSConfig Accounts /ResetOwner /SQLInstance:ServerName /DatabaseName:DatabaseName
    Replace ServerName with TFS2 (New TFS machine) and DatabaseName is TFS_Configuration. After replacing the command will be as follows.
    TFSConfig Accounts /ResetOwner /SQLInstance:TFS2 /DatabaseName:Ttf_Configuration
    If you specify the configuration database, this command will change the ownership for all of the databases for Team Foundation Server.
    [Note: If specified database name is incorrect then, it would show the following error
    “Logging sent to file C:\ProgramData\Microsoft\Team Foundation\Server Configuration\Logs\CFG_ACCT_AT_0927_090003.log
    Command: accounts
    TfsConfig - Team Foundation Server Configuration Tool
    Copyright (c) Microsoft Corporation. All rights reserved.
    Validating Inputs
    TF246017: Team Foundation Server could not connect to the database. Verify that the server that is hosting the database is operational, and that network problems are not blocking communication with the server.”]
     VIII.            Update all the service Accounts.We must have to update the service account for Team Foundation Server (TFSService) and the data sources account (TFSReports). Even if these accounts have not changed, you must update the information to help ensure that the identity and the format of the accounts are appropriate for the new server.

    To update the service Account
    1.    Open a Command Prompt window, and change directories to c:\Program Files\Microsoft Team Foundation Server 2010\Tools
    2.       At the command prompt, type the following command to add the service account for Team Foundation, where DatabaseName is the name of the configuration database (by default, TFS_Configuration):
    TfsConfig Accounts /add /AccountType: ApplicationTier /account:AccountName /SQLInstance:ServerName/DatabaseName:DatabaseName
    In the above command replace ServerName with TFS2, DataseName as Tfs_Configuration and AccountName as <domain>\TFSService. After replacing the command will be as follows.
    TfsConfig Accounts /add /AccountType:ApplicationTier /account:SWG\TFSService /SQLInstance:TFS2 /DatabaseName:Tfs_Configuration
    [Note: If the account exists, then you will get “Already a member” message]
    3.       At the command prompt, type the following command to add the data sources account:
    TfsConfig Accounts /add /AccountType:ReportingDataSource /account:AccountName/SQLInstance:ServerName /DatabaseName:DatabaseName
    In the above command replace ServerName with TFS2 And DataseName as Tfs_Configuration. After replacing the command will be as follows.
    TfsConfig Accounts /add /AccountType:ReportingDataSource /account:SWG\TFSServer /SQLInstance:TFS2  /DatabaseName:Tfs_Configuration
         IX.            Register the Tfs_Configuration Database to the TFS Server.We must have to register the Tfs_Configuration Database to the new Team Foundation Server. This step is missing from the above given link.TFSConfig registerDB /sqlInstance:TFS2 /databaseName:Tfs_Configuration
    [Note: This command will also start the Team Foundation Server Job Agent.]
           X.             Update the URL for the Application Tier Server.
    To update the URL in the application Tier Server
    ·         Open the Team Foundation Server Administrative Console
    ·         Change to Application Ties in the navigation bar and click on Change URLs
    ·         Change the URLs accordingly and test
    [This might throw an error ]

         XI.            Verify the Users and Permissions using the administrative Console.

       XII.            Connect to the new machine TFS2

    Some Challenges you may face :

    1)       Installing and configuring TFS. We have to make sure that the current user should have sysadmin permissions and admin privileges in the system as well as TFS also.
    2)       We must have to take the backup of Default collection from the old machine.
    3)       Uninstallation of the TFS will leave some residues in the database as well as default collection. We must have to remove them manually. For that we have to access the URL from the Internet Explorer and manually delete the Default collection.

    This document is prepared on the based of the Link.