1

We have a dot net app and we use Jenkinsfile for the build. Jenkinsfile performs docker build for entire app that has a dockerfile with below instructions for sonar analysis :-

RUN if("$Env:SKIP_SQ" -eq 'NO') { "C:\build\sonar-scanner-msbuild-4.6.2.2108-net46\SonarQube.Scanner.MSBuild.exe" begin /k:"***" /d:sonar.exclusions=**/Foundation/Themes/code/Scripts/**,**/Project/***/code/SiteJS/Plugins/**,**/Project/***/code/SiteJS/Rates/** }

RUN msbuild .\***.sln  /p:DeployOnBuild=True /p:Configuration=Release /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:PublishUrl=C:\out\website /m

RUN if("$Env:SKIP_SQ" -eq 'NO') { "C:\build\sonar-scanner-msbuild-4.6.2.2108-net46\SonarQube.Scanner.MSBuild.exe" end }

The first RUN instruction in the dockerfile begins the sonar analysis as documented under :- https://docs.sonarqube.org/latest/analyzing-source-code/scanners/sonarscanner-for-dotnet/

There is a property we can pass as below in this first RUN instruction :-

sonar.qualitygate.wait=true

So it would be like :-

RUN if("$Env:SKIP_SQ" -eq 'NO') { "C:\build\sonar-scanner-msbuild-4.6.2.2108-net46\SonarQube.Scanner.MSBuild.exe" begin /k:"***" /d:sonar.qualitygate.wait=true /d:sonar.exclusions=**/Foundation/Themes/code/Scripts/**,**/Project/***/code/SiteJS/Plugins/**,**/Project/***/code/SiteJS/Rates/** }

Will that work, how do we invoke quality gate condition here so the build fails if the checks are not met.

Ashley
  • 1,447
  • 3
  • 26
  • 52

0 Answers0