当前位置:网站首页>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
边栏推荐
- 热键,界面可视化配置(界面交互)
- Shell instruction learning 1
- [machine learning] scikit learn introduction
- jdbc入门\获取数据库连接\使用PreparedStatement
- Strategy for improving the conversion rate of independent stations | recovering abandoned users
- Breadth first search topics (BFS)
- No.1.#_6 Navicat快捷键
- Sword finger offer II 022 The entry node of the link in the linked list
- Step on the pit: Nacos uses startup CMD - M standalone startup error
- io.lettuce.core.RedisCommandExecutionException: ERR wrong number of arguments for ‘auth‘ command
猜你喜欢
Establish excel bookkeeping book through setting context menu
Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
Batch import of orange single micro service
2 - principes de conception de logiciels
转置卷积(Transposed Convolution)
Data mining -- understanding data
Flutter nouvelle génération de rendu graphique Impeller
mysql中duplicate key update
2-軟件設計原則
第36期《AtCoder Beginner Contest 248 打比赛总结》
随机推荐
Markdown syntax support test
Frequently asked interview questions - 2 (computer network)
Duplicate key update in MySQL
Use of qwbengneview and qwebchannel.
多线程与高并发(3)——synchronized原理
Establish excel bookkeeping book through setting context menu
jdbc入门\获取数据库连接\使用PreparedStatement
【华为机试】考试得分总数(如何处理答错的情况?回溯一次,代表答错一题)
Xiuxian real world and game world
The 8th Blue Bridge Cup 2017 - frog jumping cup
POI exports to excel, and the same row of data is automatically merged into cells
Common protocols of OSI layer
MySQL的锁机制
Date增加天数
Hotkeys, interface visualization configuration (interface interaction)
After adding qmenu to qtoolbutton and QPushButton, remove the triangle icon in the lower right corner
MDN文档里面入参写法中括号‘[]‘的作用
Golang通过exec模块实现Ping连通性检测案例
Differences between auto and decltype inference methods (learning notes)
Strategy for improving the conversion rate of independent stations | recovering abandoned users