Skip to content

Commit

Permalink
Merge pull request #10 from nosinovacao/task-update-versions
Browse files Browse the repository at this point in the history
Upgrade versions of dotnet, sonarscanner and docker
  • Loading branch information
calexandre authored Aug 11, 2019
2 parents 4ca4c26 + b2f8627 commit da44e94
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
FROM microsoft/dotnet:2.2.103-sdk
FROM mcr.microsoft.com/dotnet/core/sdk:2.2.401

ENV SONAR_SCANNER_MSBUILD_VERSION 4.5.0.1761
# reviewing this choice
ENV DOCKER_VERSION 18.06.1~ce~3-0~debian
ENV SONAR_SCANNER_MSBUILD_VERSION 4.6.2.2108

ENV DOCKER_VERSION 5:19.03.1~3-0~debian-stretch
ENV CONTAINERD_VERSION 1.2.6-3

# Install Java 8
RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y openjdk-8-jre

Expand All @@ -20,7 +23,7 @@ RUN apt-get install -y \
$(lsb_release -cs) \
stable" \
&& apt-get update \
&& apt-get install -y docker-ce=$DOCKER_VERSION
&& apt-get install -y docker-ce=$DOCKER_VERSION docker-ce-cli=$DOCKER_VERSION containerd.io=$CONTAINERD_VERSION

# install nodejs
RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - && apt-get install -y nodejs autoconf libtool nasm
Expand Down
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ It also allows you to run Docker in Docker using a docker.sock mount.

This image was built with the following components:

* dotnet-sdk-2.2.103 (stretch)
* SonarQube MSBuild Scanner 4.5.0.1761
* dotnet-sdk-2.2.401 (stretch)
* SonarQube MSBuild Scanner 4.6.2.2108
* OpenJDK Java 8 (required for Sonar Scanner)
* Docker binaries 18.06.1 (for running Docker in Docker using the docker.sock mount)
* Docker binaries 19.03.1 (for running Docker in Docker using the docker.sock mount)
* nodejs 11

[![Docker Build Status](https://img.shields.io/docker/build/nosinovacao/dotnet-sonar.svg)](dotnet-sonar)
Expand All @@ -18,6 +18,7 @@ This image was built with the following components:

Tags are written using the following pattern: `dotnet-sonar:<year>.<month>.<revision>`

* dotnet-sonar:19.08.0
* dotnet-sonar:19.01.0
* dotnet-sonar:18.12.1
* dotnet-sonar:18.09.0
Expand Down Expand Up @@ -53,6 +54,7 @@ dotnet /sonar-scanner/SonarScanner.MSBuild.dll end /d:sonar.login="<SonarQubeSe

**Outside container:**

Simple Usage:
```bash
docker run -it --rm -v <my-project-source-path>:/source nosinovacao/dotnet-sonar:latest bash -c "cd source \
&& dotnet /sonar-scanner/SonarScanner.MSBuild.dll begin /k:sonarProjectKey /name:sonarProjectName /version:buildVersion \
Expand All @@ -61,6 +63,40 @@ docker run -it --rm -v <my-project-source-path>:/source nosinovacao/dotnet-sonar
&& dotnet /sonar-scanner/SonarScanner.MSBuild.dll end"
```

Advance Usage:

```bash
docker run -it --rm \
-v <my-project-source-path>:/source \
-v <my-nugetconfig-source-path>:/nuget \
dotnet-sonar:19.08.0 \
bash -c \
"cd source \
&& dotnet /sonar-scanner/SonarScanner.MSBuild.dll begin \
/k:<ProjectName> /name:<my-project-name> /version:<my-project-version> \
/d:sonar.host.url="<my-sonar-server-url>" \
/d:sonar.login="<my-sonar-server-user>" \
/d:sonar.password="<my-sonar-server-pass>" \
/d:sonar.cs.opencover.reportsPaths='tests/**/coverage.opencover.xml' \
&& dotnet restore --configfile /nuget/NuGet.Config \
&& dotnet build -c Release \
&& dotnet publish -c Release -r linux-x64 -o deployment \
&& dotnet test --no-build -c Release --filter "Category=Unit" --logger trx --results-directory testResults /p:CollectCoverage=true /p:CoverletOutputFormat=\"opencover\" \
&& dotnet /sonar-scanner/SonarScanner.MSBuild.dll end \
/d:sonar.login="<my-sonar-server-user>" \
/d:sonar.password="<my-sonar-server-pass>""
```

The script above does the following:
* Mounts your project folder to the container's /source folder
* Mounts your nuget config to the container's /nuget folder (optional if no private nuget server is used)
* Begins the sonarscanner with the sonarqube server credentials
* Performs a dotnet restore with the nuget config in /nuget folder
* Executes the build command
* Publishes the build to the deployment folder
* Runs the tests and stores the test results in testResults folder. Change this command to your unit tests needs
* Ends the sonarscanner and publishes the sonarqube analysis results to the sonarqube server

### Using Jenkins pipeline

The following pipeline code will:
Expand Down

0 comments on commit da44e94

Please sign in to comment.