Web前端项目扫描


[root@jenkins-master devops-web-service-master]# ls
build   index.html   Jenkinsfile1  package-lock.json  src
config  Jenkinsfile  package.json  README.md          static

[root@jenkins-master devops-web-service-master]# npm install
[root@jenkins-master devops-web-service-master]# npm run build

[root@jenkins-master devops-web-service-master]# ls dist/static/
css  js
[root@jenkins-master devops-web-service-master]# ls dist/static/js/
app.2f2e5edd9af2c59aa514.js      manifest.2ae2e69a05c33dfc65f8.js      vendor.0aad2172a75b8ed4f46c.js
app.2f2e5edd9af2c59aa514.js.map  manifest.2ae2e69a05c33dfc65f8.js.map  vendor.0aad2172a75b8ed4f46c.js.map
[root@jenkins-master devops-web-service-master]# cat myproject.properties 
sonar.projectKey=devops-web-service
sonar.projectName=devops-web-service
sonar.projectVersion=1.0
sonar.sources=dist/static/js
sonar.host.url=http://139.198.170.122:9000
sonar.login=admin
sonar.password=admin
sonar.sourceEncoding=UTF-8
[root@jenkins-master devops-web-service-master]# sonar-scanner -Dproject.settings=myproject.properties


sonar-scanner \
  -Dsonar.projectKey=devops-web-service \
  -Dsonar.projectName=devops-web-service \
  -Dsonar.sources=src \
  -Dsonar.host.url=http://139.198.166.235:9000 \
  -Dsonar.login=8b84bf7320e1f6f43c5b7801af3ef0ab223c8d85 \
  -Dsonar.projectVersion=2.0 \
  -Dsonar.ws.timeout=30 \
  -Dsonar.projectDescription="my first project!" \
  -Dsonar.links.homepage=http://192.168.1.200/devops/devops-maven-service \
  -Dsonar.links.ci=http://192.168.1.200:8080/job/demo-pipeline-service/ \
  -Dsonar.sourceEncoding=UTF-8 

版本不同  -Dsonar.projectVersion=2.0,可以生成不同版本,不同版本可以对比 

 

 

 

Golang项目扫描


sonar-scanner -Dsonar.projectKey=devops-golang-service \
-Dsonar.projectName=devops-golang-service \
-Dsonar.sources=src \
-Dsonar.login=admin \
-Dsonar.password=admin \
-Dsonar.host.url=http://192.168.1.200:9000


## 有测试用例的情况
sonar.exclusions=**/*_test.go
sonar.tests=.
sonar.test.inclusions=**/*_test.go