Continuous Deployment with AX2012 and TeamCity (part 2)


Continuous Deployment with AX is a two part gig.  First you need a building software like Microsoft's Release Management or JetBrain's Team City ( covered in part 1 ).  Second, you need to be able to call all of the building activities within AX itself such as synchronizing with Version Control, x++ compile, CIL compile, and so on.  This is what we will cover today, and will follow up with how to automate the entire process ( part 3 ).

Systems like Team City unfortunately do not understand how to compile X++ or any of the trimmings that we need to get a modelstore ready to roll.  We need to use AX for these tasks and a great place to start are the Startup Command classes which extend from SysStartupCmd:

You'll see there are already options for Compile, CompileIL, DB Sync.  One obvious option we are missing is the ability to synchronize with TFS, of which I created a class below:



Now, you can call these all from the command line using AX32.exe, I'll show you how to do this in our next post.  This is great, however we want the ability to log each of these steps and halt if errors occur.  

Creating a simple build logger utility class, we capture the class that calls the log command, and output the contents of the infolog to a file.  In this way, we can monitor for informational, warning, and error exceptions.

In the method you'll see we are using the directory location of the server, this is because the AXBuild.exe utility already outputs an HTML log file here.

We call this class from the shutdown() method on each of the startup classes, and effectively log the work.

Next post we'll tie all of this together into a cohesive building machine!