Code Monkey home page Code Monkey logo

dotnetcorejenkins's Introduction

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

dotnetcorejenkins's People

Contributors

nanghele avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.