Living. Dreaming. Coding
Continuous integration in Azure DevOps

Continuous integration in Azure DevOps

Continuous Integration allows a developer to make sure their code builds correctly and that unit tests are run after each check in. There are of course a lot more things you can do with it but on this article I’ll focus on these two first. I’ll be using Azure DevOps as an environment but there are other alternatives like Jenkins and Team City. Azure DevOps has a lot more functionality but for this post we are going to use Azure Pipelines. Let’s get started!

The first thing we need is a project to use. You can use any sort of project for example a: Core site, Universal Windows Platform application, Winforms application, WPF anything will work. For this ‘simple’ example I’ll create a Console Application with some test.

This is just a blank .net Core app and and test project with a successful test as you can see below. Let’s hope it doesn’t fail :-).

    public class UnitTest1
        public void TestMethod1()

To get things things going we need to have a azure devops account. After that we use the “create project” button to create a new project. In there we can host our code, user stories etc. After checking in with GIT we get the following result so then we know our code is in there,

Now we need to go to Pipelines and select builds.

Press the new pipeline button that is displayed.

Here you can select where your code is located. Since we also stored our code in Azure DevOps we select the Azure Repos Git option and select our “team project”, “Branch” and Repository.

No we select the core template. There are a lot of different project templates but since we created a .net core project we use that. It will now automaticlly create a build configuration. That can be seen below:

It consists of a few steps:

  • Restore our NuGet Packages
  • Build our core application
  • Run all tests found in our test project
  • Publish our site (which we don’t have so remove this)
  • Publish all build artifacts

The title of this posts contains Continuous Integration however currently our build only runs manually. This can be done using the “Save and Queue” button however this is not optimal. I want to run it after each “check in”. This can be done in the triggers tab.

This configures our build to be run after each check in. You can also schedule another build to be run at 07:00 in the morning. Usually you have multiple builds defined depending on your deployment strategy, Test strategy or something else. When a you press “Save and queue” a build will be scheduled and run as can be seen below. The steps from your build steps are displayed in order and the output of them can be viewed.

When all the steps are finished you can see that my build was run sucessfully.

Using a build server helps me with a couple of things:

  • Make sure or code compiles on a clean check out
  • Make sure the code still compiles after each check in
  • Execute any tests that I have so that I know that I didn’t wreck anything.

Leave a Reply

Your email address will not be published.