Last year I blogged about Team City , well I have been looking at it again recently. In that time they have even changed their logo!
Lets start with thinking about what I want my Continuous Integration server to do.
- Check out my code from source control (usually master but all feature branches would be even better)
- Configure specific setting for build
- Build my code
- Build my databases
- Run any unit tests
- (Optional) Run deployment to Azure Test/Live site
There are probably other things I want to achieve but I will start with these six.
- Checking out code from source control is something Team City does out of the box, so I can safely say I have done this now. It even monitors a branch for changes and initiates a new check out.
- Team City allows you to create specific build steps so in theory you can have multiple builds for every variation of settings that you want for your code. I have not tried this yet apart from building with the default config, but I don’t expect it will be too difficult.
- I have managed to get my code to build with Team City, it took a bit of tweaking the different build steps but wasn’t too difficult. Team City has a visual studio build agent which takes you solution file and does what it needs to. The one problem I have found with this step is that I get errors with my tests if I select a Debug config instead of Release.
- Databases are always the problem part of the deployment. So far I have manually deployed my databases but I intend on revisit this step. A stackoverflow post suggests that I can run SQL code via Team City in the following way by creating a command line executable:
Command executable: c:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe Command parameters: -S [ServerName] -i [PathToSQLScript]
I have yet to try this but I am hopefully that it will just work. Dropping a database and restoring a back and then running different SQL scripts is all possible from TSQL, so I should be OK. Watch this space for more details.
- Running the unit tests got me stuck for a while. I tried setting it up using VSTest or MSTest neither worked mainly because a config file wasn’t being copied with the test binaries. When I tried using NUnit it just worked. The tests that failed gave me a few config settings to change.
- I have powershell scripts that deploy to Azure websites, I think that these could form the basis of a deployment to Azure. Again the difficult step here may end up being deploying all the different databases to Azure. This is also the riskiest step as I need to connect to live servers which is why I will leave this to last, at the very least I could generate scripts that do a full deployment.
That’s it for now. Once I have this all working I will revisit again with details of the database steps as I am expecting a few challenges to overcome. What have you used a CI Server for? Are there other things I want to achieve from a project like this? Why not contact me or leave a comment below