当前位置:网站首页>2.devops-sonar安装
2.devops-sonar安装
2022-04-23 05:41:00 【Pingszi】
1.目标
安装sonar社区版8.9.1,并与gitlab集成,进行代码检查;
2.安装步骤
2.1.创建数据挂载目录
mkdir -p /data/sonar
#**第三方扩展插件
mkdir /data/sonar/extensions
#**数据文件,比如es(sonarqube依赖,官方镜像中内置es)
mkdir /data/sonar/data
#**日志文件
mkdir /data/sonar/logs
2.2.安装sonar
sonar新版不支持mysql,需要依赖postgresql数据库;
- sonar.jdbc.url:postgresql数据库连接信息;
- sonar.jdbc.username=postgres postgresql数据库用户名
- sonar.jdbc.password=postgres postgresql数据库密码
docker run -d --name sonar \
-p 8002:9000 \
-e sonar.jdbc.url=jdbc:postgresql://172.6.0.12:8434/sonar \
-e sonar.jdbc.username=postgres \
-e sonar.jdbc.password=postgres \
-v /data/sonar/extensions:/opt/sonarqube/extensions \
-v /data/sonar/logs:/opt/sonarqube/logs \
-v /data/sonar/data:/opt/sonarqube/data \
sonarqube:8.9.1-community
访问路径:http://127.0.0.1:8002,用户名/密码:admin/admin
2.3.汉化
在宿主机的数据挂载目录data/sonar/extensions/downloads下载汉化包,注意汉化包的sonar的版本要一致;
#**下载汉化包
wget https://github.com/xuhuisheng/sonar-l10n-zh/releases/download/sonar-l10n-zh-plugin-8.9/sonar-l10n-zh-plugin-8.9.jar
#**重启容器
docker restart sonar
3.使用
3.1.创建令牌
点击 用户头像 > 我的账号 > 安全 > 填写令牌名称 > 生成
3.2.gitlab-cicd集成
提交代码到gitlab develop分支后,自动运行sonar代码检查;
- 修改gitlab环境的maven配置文件setting.xml
<profiles>
<!-- sonar配置 -->
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- sonar地址 -->
<sonar.host.url>http://172.6.0.10:8002/</sonar.host.url>
<!-- 上一步创建的令牌 -->
<sonar.login>cce44014dc5496c9c444a2cf1fde46cd735120b</sonar.login>
</properties>
</profile>
</profiles>
<activeProfiles>
<!-- sonar配置 -->
<activeProfile>sonar</activeProfile>
</activeProfiles>
- 修改项目.gitlab-ci.yml配置
# 开发分支sonar质量检测
sonar:dev:
stage: sonar
image: $REGISTRY/gaojie/maven:3-jdk-8
variables:
#**上一步创建的令牌
SONAR_TOKEN: "cce44014dc5496c9c444a2cf1fde46cd735120b"
#**sonar地址
SONAR_HOST_URL: "http://172.6.0.10:8002/"
GIT_DEPTH: 0
script:
- mvn verify sonar:sonar
allow_failure: true
only:
- develop
4.遇到的问题
启动失败:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 解决:修改docker宿主机的es配置/etc/sysctl.conf
vim /etc/sysctl.conf
添加参数:vm.max_map_count=262144
sysctl -p
版权声明
本文为[Pingszi]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zhouping118/article/details/118605960
边栏推荐
- TypeScript interface & type 粗略理解
- 合约锁仓漏洞
- catkin_ What did package do
- Excel obtains the difference data of two columns of data
- QSslSocket::connectToHostEncrypted: TLS initialization failed
- refused connection
- SQL语句简单优化
- 2 - software design principles
- Contract lock loophole
- The role of brackets' [] 'in the parameter writing method in MDN documents
猜你喜欢
Duplicate key update in MySQL
C语言——恶搞关机小程序
Issue 36 summary of atcoder beginer contest 248
多线程与高并发(3)——synchronized原理
C language - Spoof shutdown applet
Flutter 新一代圖形渲染器 Impeller
MySQL lock mechanism
Hongji micro classroom | cyclone RPA's "flexible digital employee" actuator
OSI层常用协议
Fletter next generation graphics renderer impaller
随机推荐
Several examples of pointer transfer, parameter transfer, value transfer, etc
Hongji | how does HR carry out self change and organizational change in the digital era?
QT drawpixmap and DrawImage blur problem
2 - software design principles
7-10 longest symmetric substring (25 points) (violence problem solution) C language
[machine learning] scikit learn introduction
热键,界面可视化配置(界面交互)
Dwsurvey is an open source questionnaire system. Solve the problem that cannot be run and modify the bug.
Parameter analysis of open3d material setting
Data mining -- understanding data
多线程与高并发(3)——synchronized原理
Redis经典面试题总结2022
引航成长·匠心赋能——YonMaster开发者培训领航计划全面开启
Similarities and differences between vector and array (notes)
Error 2003 (HY000) when Windows connects MySQL: can't connect to MySQL server on 'localhost' (10061)
Frequently asked interview questions - 3 (operating system)
实体中list属性为空或者null,设置为空数组
windows连接mysql出现ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (10061)
50 SQL exercises, answers and detailed analysis
Frequently asked interview questions - 1 (non technical)