Breakfast: Creating your CI pipeline for net core app container and AzureDevOps Part 1/4 – Code and Build Pipeline

azuredevops-2x

In this series, I will guide you to create a complete CI (build) pipeline in Azure DevOps, covering all necessary aspects to build a full net core application (an API service), and deploying to docker hub.

The aspects covered in this series are:

  • Get source code from GitHub
  • Code Analysis
  • Unit Tests
  • Unit Tests coverage
  • Build DockerFile
  • Push DockerFile to DockerHub
  • Publish artifacts for CD pipeline

Looking at the steps above, it looks simple to achieve, but while I was creating the pipeline, I´ve face some challenges to resolve to fully attend all aspects above.

This series are divided in 4 topics:

  1. The code and Build Pipeline
  2. The code analysis and unit tests steps
  3. Building and publishing your Docker image
  4. Final steps and summary

Part 1 – Code and Build Pipeline

Code

In this part I will show how to create a simple repository and a simple web api application in net core using swagger

I use Github as repository for this demo, but you can use AzureDevops Repo or even Bit Bucket as well.

Get the code repo here, you can use it in the following steps:

https://github.com/aledaccas/net-core-svc-devops-sample

The code consist in two projects, a web api application and a test project. The web api contains basic functionalities using the concepts of DI (Dependency Injection). The test project mocks the dependency and test it to produce the % of code coverage of your application.

Build Pipeline

To create your build pipeline, access your Azure Devops subscription (https://dev.azure.com/), create a project (in my case net-core-svc-devops-sample) and access the build pipelines list (https://dev.azure.com//net-core-svc-devops-sample/_build). Create a new pipeline by clicking the New pipeline button.

breakfast-creating-your-ci-pipeline-for-net-core-app-container-and-azuredevops-part-1-4-code-and-build-pipeline-01

A new page will ask to select your code repository, you can use the Azure Repos Git, GitHub, Subversion, Bitbucket or another git version control. I will use the example GitHub repository (https://github.com/aledaccas/net-core-svc-devops-sample). Click Continue

breakfast-creating-your-ci-pipeline-for-net-core-app-container-and-azuredevops-part-1-4-code-and-build-pipeline-02

In template page, select empty template and apply. The result will be a empty pipeline with one agent job. Change the pipeline agent pool to Hosted Ubuntu 1604. This will be necessary to build the docker image in linux version.breakfast-creating-your-ci-pipeline-for-net-core-app-container-and-azuredevops-part-1-4-code-and-build-pipeline-03

Press Ctrl+s to save your pipeline. Now you are ready to add the tasks to test, analyze and build your net core container image. Check next post for unit test and quality control.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s