Create your first CI Pipeline in 10 minutes or less

During your DevOps journey typically the first item you will want to do (after establishing a good process for the team) is setup a Continuous Integration (CI) build. What does this mean in practical terms? Basically TFS/VSTS has the built-in capability of running a build anytime code changes in a certain repository (or repositories). This is a great practice to institute as it helps minimize the possibility of having “broken” code in your protected branches.

VSTS (Visual Studio Team Services) has a great and simple mechanism to help promote this best practice. Below I will walk you through how to setup a CI pipeline (we’ll discuss Continuous Deployment [CD] in the next follow-up post).

Pre-Reqs:

1. A free Microsoft account (sign up here)

2. VSTS account (free for up to 5 folks to collaborate. Sign-up here)

3. (optional) A build server/agent (only required for Team Foundation Server, this is built in to VSTS)

4. A code repository and sample application to compile (In this example I’m using git and a sample .NET Core web app created by Visual Studios)

Ok first thing is once we have our Team Project setup and selected we need to open Visual Studios and upload the code. Once this is done then we can configure the build to run dynamically on-demand.

Getting Started:

1. Create a new repo (if needed) in VSTS’s page. Go to Code, New Repository and give it a name.

git1

git2

2. In Visual Studio connect to our new Team Project’s repo and create a new sample solution (or upload existing code) using the New Project Wizard:

git3

git4

Tip: Make sure the newly created solution compiles before checking it in.

Once it compiles then Stage and Commit it to our newly created repo and Sync our changes to VSTS.

git5

git6

3. Back in VSTS let’s create our build definition that will run each time the code in this repo is modified.

git7

Click on Set Up Build and select the pre-built template that matches .NET Core web apps (this simply adds the common steps this application needs, it can be modified as needed)

git8

Be sure to check the box for “Enable Continuous Integration” and select the branch(es) we want to kick off this build once code is committed (checked-in).

git9

That’s it! Thats the minimum number of things we need to get a CI build up and running. We can use the hosted build agent and not need to do any configuration on any server. Couldn’t be simpler.

4. Last step is to kick off the build and make sure it’s successful. If not re-check that it compiles locally in Visual Studios and that we didnt miss a step somewhere in the process.

git10

As usual feel free to reach out if you need assistance or have comments on this blog.