Based on standard deployment practice that we follow at Headspring, our project too, has tarantino console deployer in place. This consoloe deployer is triggered by Cruise Control project. This set up enables our Product Owner team to push the button anytime they want to get latest version of application.
As I mention above, process of deployment involves manual trigger on cruise control web dashboard or through local tray client (Yes, we are using CruiseControl.Net). CCNet project then passes call to tarantino console deployer which in turn uses batch file to run nant script. This nant script read environment specific variable like database setting, destination path for web app and related schedule jobs etc. We abstracted this in single bat file which reads all these variable from environment variables. Hence the main batch file will just need to set bunch of environment variable before calling these common batch file. The main batch file looks like this:
1: SET variable1=somevalue
2: SET variable2=someothervalue
3:
4: CALL CommonDeploy.bat
And the common deploy batch file is:
1: nant\nant.exe -buildfile:deployment.build -D:variable1="%variable1%"-D:variable2="%variable2%"
So bottom line is , CCNet calls tarrantino app which passes call to Environment specific main batch file which in tern passes the call to common batch file( after setting required environment variables, of course).
Recently we started getting complaint from Product Owner team that some of the data is missing from testing environment. This was some meta data which gets generated as one of the later step during deployment. After looking at NAnt output from CCNet dashboard, I realize that failure from within common deployer batch file was not getting propagated to upper level and hence CCNet was happily showing status as green even after those inner failure. This failure then stopped execution of last step which generate meta data in question.
This was classic nested batch file problem. After googling here and there and experimenting my own idea, I got hint from Matt and boom we fixed it. Here is our solution. Our new batch files looks file this now:
Environment specific Main Batch file:
1: SET variable1=somevalue
2: SET variable2=someothervalue
3:
4: CALL CommonDeploy.bat
5: if "%ERRORLEVEL%"=="0" goto SuccessfullEnd
6: echo Failure: Failed while deploying Enhanced Version
7: exit /B %ERRORLEVEL%
8:
9: :SuccessfullEnd
10: echo Success: Both Enhanced and Basic Version are deployed successfully.
11: exit /B 0
Common Deploy batch file:
1: nant\nant.exe -buildfile:deployment.build -D:variable1="%variable1%" -D:variable2="%variable2%"
2: exit /B %ERRORLEVEL%
Key here was to report proper error level to your immediate parent. Do I need to say anything now:)
Till next time…..Happy coding