Friday, October 22, 2010

Work Flow of Build Automation

You can also see my code project article Work Flow of Build Automation
Every solution has own set of configuration. So operations needed to do for automated build system depend on project. Here I have suggested effective workflow and operations which is same for every project.
Cruise control is a fantastic tool with which you can automate your build and implement continuous integration in your team very easily. It is also very easy to integrate other service output Unit test, NCover result to improve build process and ensure good and deployment product.
In team environment we need to ensure my code that I checked in source control do not break build and also have to ensure that my code is also deployable.To ensure that what we have checked in do not break build, we can build solution by build automation tools after every check in or can do pre-commited build ( teamcity CI tool) which ensure last checked in code is secured for team development. After successful build we can created setup file or deployable output but it not needed after every commit which increase our automated process time . But to ensure deployable output/setup file is also safe we can automatically create setup file by doing nightly build. We can do easily by cruise control <triggers> options.
Here after 60 seconds CCNet trigger to check any new code is committed in SVN . If it find any latest commit by developer then it run NAnt script. Ant with schedule trigger it run Nant at 6am with force build which does not depends on any lealest code is committed in SVN or not. If you want you create Setup file/deployable output when Force buid condition is true otherwise only rebuild solution then you can create an target in CCNet which make this decision according to your BuildCondition .
Here in this target (Run) which calls other two target '”OnlyRebuild” and “RebuildAndCreateSetup” target. When you press ‘Force Build” button of CCNet or with BuildCondition =”ForceBuild”  it will call target “RebuildAndCreateSetup” otherwise for formal check in of source code it will run OnlyRebuild to ensure your source code is always deployable.
Cruise control triggers (<intervalTrigger seconds="60"/>) after certain time to check anything is checked into source control or with force build and start build process. In my project our source control is maintain by our client which we access through internet. If we try to checkout whole solution after every check in for build then take much time but we only need to merge last checked in files. So we create a folder say SVNFOLDER where we checkout whole solution one time and after that every time cruise control only update with latest files but we will not build solution in that checkout location for ensuring our code do not conflict anytime when taking latest changes by cruise control. We create another folder say BUILDFOLDER where we copy fresh code from SVNFOLDER and perform all operations to build solutions. These operations I have done using NAnt. After updating lasted code cruise control call NAnt script as defined in config file. 
NAnt Operation can be described by following steps
1. Copy whole source from SNVFolder to BuildFolder
2. Get then SVN Revision Number and CCNet level for creating version number. version number as <CCNetLevel>.<SVN Revision>
3. Change GlobalAssembly.cs with version number and other settings and also change web.conf with release configuration.
4. Run MSBuild with all configuration to rebuild solution.
5. Run Unit Test  if your project contains Unit Test.
6. Run NCoverage  (optional)
7. You can also run FxCop and other tools for analyzing your build. This step is also optional.
8. Create Setup file or other deployable output.
9. Copy the deployable output into SetupFolder  with version number.
When ForceBuild is clicked from CCNET or when BuildCondition = “ForceBuild”  then it do all operations as mentioned above  from 1 to 9. And for regular source code check by developer NAnt only perform step 1 to 7 to ensure developer last checkin  is safe to create deployable output.

The work flow of CCNET is given here


No comments:

Post a Comment