Skip to content

nanghele/dotnetcorejenkins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Jenkins to build a .Net Core project

Abstract

This is an example for using Jenkins inside a docker container to let CI take place in a .Net Core environment. Microsoft is moving fast in the direction of docker and linux systems, Docker Hub is full of usefull images for any use in the MS world. What I did is quite simple, I have used microsoft/dotnet sdk in a debian stretch enviroment to run Jenkins and configure it for a basic CI block. You can follow this instruction for any linux, windows, Mac-OsX machine which has a working docker and shell.

Getting started

First checkout this project and then create the jenkins-home directory to persist jenkins configuration locally. Otherwise you could create a docker volume and mount it from the container, that's up to you , in this example I mount a local directory.

mkdir jenkinsCI
git clone https://github.com/nanghele/dotnetcorejenkins.git jenkinsCI
cd jenkinsCI
mkdir jenkins-home

Now it's time to start your container

# using docker cli
docker run -p 8080:8080 -v ./jenkins-home:/var/lib/jenkins dotnetjenkins:1.0
# or if you prefer docker-compose
docker-compose up -d

In a few seconds you can browse Jenkins on http://localhost:8080 and you will have to start configuration

Since I would like to get code coverage report I will install the Cobertura plugin and unselect some uneeded plugins.

Let's go on.

After few minutes depending on your machine you will be ready to create your first job. I will skip the congifuration of git account and I will directly go into the compile section of the job . I used this project https://github.com/nanghele/rest_api_dot_net_template where I use Coverlet to provide a coverage report in the format of Cobertura that Jenkins is able to manage.

# Build step 1 execute shell
dotnet build
# Build step 2 execute shell
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Exclude="[xunit.*]"
# Post build step select cobertura report plugin
cobertura xml report pattern =>  cobertura.coverage.xml

and at the end you will get your coverage report

About

Jenkins docker for CI in .Net core projects

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published