Automated Builds – Part 1: Introduction
Last few days I have been working on running automated builds for Business Central on our self-hosted server using Azure DevOps.
There are already few articles in the Internet where you can read about it. You can find the good series of posts on https://freddysblog.com/ or https://jpearson.blog/. Lately also DevOps for AL extension had been released. More information here: http://www.waldo.be/2019/06/18/devops-for-al-alops-is-alive/
Despite those blogs I decided to share all of my findings and scripts with you.
What you would find on the blog
In the next few articles, starting from this one, you will be able to get more info about:
- How to setup the self-hosted agent and connect it with your Azure DevOps
- How to create a build pipeline using YAML files
- How to create the Docker Container for your builds
- How to compile and publish single extension
- How to get more than one extension from multiple repositories and install them on the created Docker Container
- How to get extension for automated tests and run it automatically in the created Docker Container
- How to publish automated tests results on Azure DevOps
- How to create a release pipeline after a successful build
Few words before start
First of all, I should say that in all my examples, which I will present, I am using NAVContainerHelper. I really like them and fully support the idea. The library is easy to use and really useful. I know that there are some inconvenience using them, but I decided to base my workflow on using them anyway.
Second of all, to start you need to have few things ready:
- Installed docker (only it) on your server where you would like to do builds. For training you can use even your laptop
- Created Azure DevOps account and the project with at least one GIT repository which has the Business Central application. However, if you want to have more complex examples you can have more than one repository and also at least one repository for the automated tests.
How the workflow will look like at the end?
In fact, after series of my articles you will have information how to build one of 4 options.
Single Extension flow
This is the simplest option. It will have below steps:
- Receive files from the repository
- Install latest version of NAVContainerHelper
- Create docker container from requested image
- Copy additional files to the container (only if necessary)
- Compile extension in the docker container
- Publish extension in the docker container
Single Extension flow with automated tests
This is the extension to the previous workflow. After publishing the extension, next steps will be processed:
- Receive files from the repository where the extension with automated tests is stored
- Compile and publish the testing extension
- Run automated tests in the docker container
- Publish the results on Azure DevOps
Multiple Extensions flow
This is the more complex example. After following this path, you will be able to build your whole project if it contains more than one extension. It is quite common approach for products which have modules. The workflow for this example looks as follows:
- Receive files from the main repository
- Install latest version of NAVContainerHelper
- Create docker container from requested image
- Copy additional files to the container (only if necessary)
After those steps there are few more which are going in the loop for each extension:
- Receive files from the repository for the extension
- Compile extension in the container
- Publish extension in the container
Multiple Extension flow with automated tests
This is the extension to the previous workflow again. After publishing all required extensions, next steps will be done related to the test applications:
- Receive files from the repository or more repositories where the extension with automated tests is stored
- Compile and publish the testing extension
- Run automated tests in the docker container
- Publish the results on Azure DevOps
Hope you will enjoy the series on the blog.