For part 4 of our Getting Started with DevOps Series, I want to introduce you to Continuous Integration (CI): Making automatic builds of our newest code available to all team members.
To keep things simple, we will start with a simple build server, which can build a C# hello world project for macOS and linux, verifying your cross-platform compatibility.
Later tutorials will introduce pipelines covering automatic tests and deployments for offline applications as well as server applications.
Creating a Build Server
Before we get into the Bouncer CI setup, let’s get a simple Build server running ourselves.
For this tutorial we will create a quick .NET Core “hello world” on GitHub.
- Create a new GitHub Repository (here is mine)
- Clone your new repository to your computer
- Open a console and navigate to your repository
- run “
dotnet new console“
- commit and push
Choosing a Build Server
There are many good build servers available. All of them have similarities and will get most jobs done.
Travis CI is free to use for open source projects and feature rich.
So it looks like Travis CI is a great place to start.
We also use Travis CI for BrutalHack.Bouncer. You can see our build reports here: https://travis-ci.org/github/BrutalHack/Bouncer/builds
Choosing an Operating System
As developers prefer different operating systems, I suggest we embrace this instead of forcing all developers to use windows or linux.
As a result, your developers are able to use the operating system of their choice. Simply have your build server run the rarest operating system in your team.
Nobody is programming on linux? Then we should build on linux.
Nobody is coding on windows? Then we should build on windows.
Our goal here is to guarantee flexibility for our team and to guarantee that our product will also be more stable on the target system.
Getting Started with Travis CI
As mentioned earlier, we will be using Travis CI with GitHub. So let’s begin by setting up Travis CI! At first we have to follow the guide in the Travis CI Tutorial to authorize TravisCI as GitHub App:
Next we create a simple .travis.yaml file in out repositories root:
This will build a C# solution from the ci-example.sln solution file with default settings.
If you click on “View Config” in the screenshot above, you will see the default configuration using linux, specifically “xenial”.
The Travis CI linux documentation tells us, that this refers to Ubuntu 16.04 Xenial Xerus.
Now let’s complete this tutorial by customizing our build config.
Specifically we want to verify our cross-platform compatibility.
As Travis CI does not support building C# projects on windows, we will only build on macOS and linux within this tutorial.
We can do this by introducing jobs in our .travis.yml file according to the Travis CI Multi OS documentation. Because our C# hello world project is created with .net core 3.1, we must define this version as described in the Travis CI C# Documentation.
After commiting and pushing our new .travis.yml, you will see the new build starting with two build jobs instead of one.
The following screenshot displays my build with the two build jobs.
You can see the full build report here at Travis CI:
Now we know how to setup automated builds, which can verify, that our code works independently of our development machine and cross-platform. Our next episodes will extend our build server to run automated tests and automatically upload releases to GitHub.