If you follow blogs about Dynamics 365 Business Central / NAV development, attended development sessions at Directions or have seen the schedule for NAVTechDays then you may have noticed the terms “CI/CD” or “pipeline” being thrown around.
What do those terms actually refer to? And how does it affect the way we approach development?
CI = “continuous integration”
CD = “continuous delivery” (or “continuous deployment”, if you prefer)
These are pretty old development concepts. Check out the Wikipedia entry if you want an overview and some of the history. I would summarise it like this.
Continuous integration: incorporate new development into your main development branch as soon as possible.
Continuous delivery: get that development in front of your end users as quickly as possible.
The concept of a pipeline is having a defined series of steps that new development goes through. Build, test, publish and install into target environment(s) – automated as much as possible
All this talk of “as soon as possible” sounds a little reckless. Is this really a good idea?
In a nutshell, we’re trying to minimise the time between identifying some changes that the customer needs (some new feature or bug fix) and those changes actually being deployed onto the customer’s system.
We want to avoid work in progress changes hanging around for ages. You’ve probably experienced the problems that come with that:
- The work becomes harder to merge back into the master branch as time goes by
- Future development dependent on these changes is held up or goes ahead with the worry it will clash with work in progress
- People start to forget, or lose interest, in why the changes were required in the first place making testing and code review harder or less effective
- The customer loses interest in the development and is less inclined to test or use the new development
All my experience is with Azure DevOps (what used to be called Visual Studio Team Services and used to be called Team Foundation Server) but other platforms provide similar functionality.
We start by defining small, discrete work items. I don’t have a fixed rule, but if the work can’t be completed in a single sprint (say, 2 weeks) then it’s probably too big and you should split it into smaller chunks.
The developer gets to work and puts their changes in for review. Pushing those changes up to the server triggers the build pipeline. Typically this is a series of tasks performed by a build agent running on a server that you control. Azure DevOps provides several options for agents hosted by Microsoft but for now they don’t provide the option we need to build AL packages.
I won’t go into detail about our build pipeline now but it includes:
- Creating a Docker container
- Compiling the AL source with the compiler included in the container
- Running the automated tests (the developer should have included new tests to cover their changes)
- Uploading the test results and the .app files (we split the product and its tests into two separate apps) as build artefacts
- Notifying the developer of the build result
By the time any of the reviewers comes to look at the code review we should already that:
- All the tests have passed
- The changes can be merged into the master branch without any conflicts
Nice. We can be much more confident hitting the Approve button knowing it passes the tests and will merge neatly with master. We get the changes incorporated back into the product quickly and have a clean starting point for the next cycle.
Delivery is a different story. At the time of writing our release process is to make the new .app package available on SharePoint. We don’t automate that.
With Dynamics NAV / BC on-premise there is scope for automating the publish & install of the new app package into target environments and tenants. That would involve the definition of a release pipeline. An agent on the target environment could collect the app package (or fob, or text file) created by the build pipeline and use PowerShell to import/compile/publish/install into one or more databases.
We don’t attempt this as in many cases we don’t control the environments that our apps are installed into. The servers are not ours to install agent software onto and be responsible for.
This is especially true of Business Central SaaS as we are developing apps for AppSource. No app package* makes it onto the platform until it has passed the AppSource validation process and deployed by Microsoft on their own schedule.
*unless it is developed in the 50,000 – 99,999 object range and uploaded.
I hope that’s whet your appetite to go and investigate some more. Before you do you’ll need to be up and running with source code management and automated tests (perhaps more of that another time).
One thought on “Business Central Development With CI/CD”