代码改变世界

sonar qube,容器内scaner(docker push)

2022-05-12 09:23  qgbo  阅读(138)  评论(0编辑  收藏  举报

------------恢复内容开始------------

1. docker  上启动server: docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9067:9000 sonarqube:latest

2. 主机(windows)打开浏览器:http://192.168.40.139:9067   修改密码之后进去,新建 project:  qgb

3. 选择manully

4. 下一步

 

 5. 安装 scanner

6. 到一个 dotnet core  项目里执行:

D:\Work\Test\WebApplication2>dotnet sonarscanner begin /k:"qgb" /d:sonar.host.url="http://192.168.40.139:9067"  /d:sonar.login="983494ef699772053c65cad63e338bd6d214a686"
SonarScanner for MSBuild 5.5.3
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
16:23:50.171  Updating build integration targets...
16:23:51.208  Fetching analysis configuration settings...
16:23:54.884  Provisioning analyzer assemblies for cs...
16:23:54.886  Installing required Roslyn analyzers...
16:23:56.073  Provisioning analyzer assemblies for vbnet...
16:23:56.074  Installing required Roslyn analyzers...
16:23:56.11  Pre-processing succeeded.

这个命令,会生成 .sonarqube 文件夹

D:\Work\Test\WebApplication2\.sonarqube>tree /F
Folder PATH listing
Volume serial number is B418-ADE9
D:.
├─bin
│ │ SonarScanner.MSBuild.Common.dll
│ │ SonarScanner.MSBuild.Tasks.dll
│ │
│ └─targets
│ SonarQube.Integration.targets

├─conf
│ │ Sonar-cs-none.ruleset
│ │ Sonar-cs.ruleset
│ │ Sonar-vbnet-none.ruleset
│ │ Sonar-vbnet.ruleset
│ │ SonarQubeAnalysisConfig.xml
│ │
│ ├─cs
│ │ SonarLint.xml
│ │
│ └─vbnet
│ SonarLint.xml

└─out

dotnet sonarscanner end /d:sonar.login="983494ef699772053c65cad63e338bd6d214a686983494ef699772053c65cad63e338bd6d214a686"

 之后,会 生成下面文件

 

 

dotnet 在镜像中 scan:

https://www.nuget.org/packages/dotnet-coverage#versions-body-tab   这里下载下面2个包。运行镜像并安装到容器中

sudo docker run -it --rm  nexus-cn:443/mcr.microsoft.com/dotnet/sdk:7.0 /bin/bash

》dotnet tool install dotnet-coverage --tool-path /bin/  --add-source / --version 17.9.3

》dotnet tool install dotnet-sonarscanner  --tool-path /bin/  --add-source / --version 5.14.0

另一个termial:

sudo docker commit 53cc286e58a1 dotnet-sonar:7.0

sudo docker push dotnet-sonar:7.0

以后的可以用这个镜像