Getting Started with Build Servers
Tags: devops, beginners, ci, tutorial
Published: 2020-10-12 19:53:49

---
title: Getting Started with Build Servers
published: true
date: 2020-08-09 13:06:31 UTC
tags: DevOps,Beginner,CI,Tutorial
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/b8o3ek1vprh3hgse2hub.png
canonical_url: https://www.justice.sh/blog/devops/devops-ep-4-build-servers/
series: Getting Started with DevOps

---

For part 4 of our [Getting Started with DevOps Series](https://justice.sh/blog/devops/getting-started/), 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.

1. Create a new GitHub Repository ([here is mine](https://github.com/Benjamin-Justice/ci-example))
2. Clone your new repository to your computer
3. Open a console and navigate to your repository
4. run “`dotnet new console`“
5. 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.

- [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/)
- [Jenkins](https://www.jenkins.io/)
- [Travis CI](http://Travis%20CI%20-%20Test%20and%20Deploy%20Your%20Code%20with%20Confidencetravis-ci.org)
- [GitHub Actions](https://github.com/features/actions)
- etc

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](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](https://docs.travis-ci.com/user/tutorial/) to authorize TravisCI as GitHub App:

![Granting Travis CI build servers access to our Github Repositories](https://docs.travis-ci.com/images/migrate/legacy-services-migration-github-apps.png)<figcaption>Granting Travis CI access to our GitHub Repositories</figcaption>

Next we create a simple .travis.yaml file in out repositories root:

 <!-- HTML generated using hilite.me -->

```
language: csharp# if your .sln file has a different name, change it here :)solution: ci-example.csproj
```

This will build a C# solution from the ci-example.sln solution file with default settings.

1. Commit
2. Push
3. Watch Travis CI build your project at [https://travis-ci.com/](https://travis-ci.com/)   
(here is [my build report](https://travis-ci.com/github/Benjamin-Justice/ci-example/builds/178866895))

[![](https://justice.sh/wp-content/uploads/2020/08/image-1024x575.png)](https://justice.sh/wp-content/uploads/2020/08/image.png)<figcaption>Travis CI building our first commit with travis CI support</figcaption>

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](https://docs.travis-ci.com/user/reference/linux/) tells us, that this refers to Ubuntu 16.04 Xenial Xerus.

### Cross-Platform Builds

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](https://docs.travis-ci.com/user/multi-os/). 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](https://docs.travis-ci.com/user/languages/csharp/).

 <!-- HTML generated using hilite.me -->

```
language: csharp# if your .sln/.csproj file has a different name, change it here :)solution: ci-example.csproj# Travis CI jobs to run multiple buildsjobs: include: # linux build with Ubuntu 18.04 "Bionic Beaver"# (https://docs.travis-ci.com/user/reference/linux/ - os: linux dist: bionic # .Net Core version 3.1.302 # (https://dotnet.microsoft.com/download/dotnet-core/3.1) dotnet: 3.1.302 # macOS build with "xcode12" image running macOS 10.15.5 with Xcode 12# (https://docs.travis-ci.com/user/reference/osx/) - os: osx osx\_image: xcode12 # .Net Core version 3.1.302 # (https://dotnet.microsoft.com/download/dotnet-core/3.1) dotnet: 3.1.302
```

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](https://travis-ci.com/github/Benjamin-Justice/ci-example/builds/179028876):

[![](https://justice.sh/wp-content/uploads/2020/08/image-2-1024x616.png)](https://justice.sh/wp-content/uploads/2020/08/image-2.png)<figcaption>Successful linux &amp; macOS builds</figcaption>

## Conclusion

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**.

Until then, you can reach out to me on [Twitter](https://twitter.com/JusticeDev) or the [BrutalHack Discord Server](https://discordapp.com/invite/4FmEwGp) for questions. I also recommend some further research in the excellent [Travis CI documentation](https://docs.travis-ci.com/user/tutorial/).

The post [Getting Started with Build Servers](https://www.justice.sh/blog/devops/devops-ep-4-build-servers/) appeared first on [justice.sh](https://www.justice.sh).