使用docker-compose快速搭建环境: SonarQube 7.9.1 + PostgreSQL 12.0
发布日期:2021-06-30 20:13:40
浏览次数:2
分类:技术文章
本文共 6070 字,大约阅读时间需要 20 分钟。
SonarQube的LTS版本以6.7和7.9较为具有代表性,这篇文章整理了一下SonarQube LTS 7.9.1 + PostGreSQL的环境搭建方式。需要注意的是从7.9版本开始 SonarQube在所有的发行版中不再支持MySQL,另外需要Java 11的支持。
SonarQube 7.9.1
这里使用Alpine版本的SonarQube 7.9.1 和PostgreSQL 12.0进行环境搭建,docker-compose.yml如下所示
docker-compose.yml文件: 示例1
liumiaocn:sonar liumiao$ cat docker-compose.7.9.1.yml version: '2'services: # database service: postgres postgres: image: postgres:12-alpine networks: - sonarnet volumes: - ./postgres/postgresql/:/var/lib/postgresql - ./postgres/data/:/var/lib/postgresql/data environment: - POSTGRES_USER=sonar - POSTGRES_PASSWORD=sonar restart: "no" # Security service: sonarqube sonarqube: image: liumiaocn/sonarqube:7.9.1 ports: - "9000:9000" networks: - sonarnet volumes: - ./sonar/data/:/opt/sonarqube/data - ./sonar/log/:/opt/sonarqube/log - ./sonar/extensions/:/opt/sonarqube/extensions - ./sonar/conf/:/opt/sonarqube/conf environment: - sonar.jdbc.url=jdbc:postgresql://postgres:5432/sonar restart: "no"networks: sonarnet: driver: bridgeliumiaocn:sonar liumiao$
docker-compose.yml文件: 示例2
liumiaocn:sonar liumiao$ cat docker-compose.7.9.1.ymlversion: '2'services: # database service: postgres postgres: image: postgres:12-alpine volumes: - ./postgres/postgresql/:/var/lib/postgresql - ./postgres/data/:/var/lib/postgresql/data environment: - POSTGRES_USER=sonar - POSTGRES_PASSWORD=sonar restart: "no" # Security service: sonarqube sonarqube: image: liumiaocn/sonarqube:7.9.1 ports: - "9000:9000" volumes: - ./sonar/data/:/opt/sonarqube/data - ./sonar/log/:/opt/sonarqube/log - ./sonar/extensions/:/opt/sonarqube/extensions - ./sonar/conf/:/opt/sonarqube/conf environment: - sonar.jdbc.url=jdbc:postgresql://postgres:5432/sonar restart: "no"liumiaocn:sonar liumiao$
启动服务
liumiaocn:sonar liumiao$ docker-compose -f docker-compose.7.9.1.yml up -dCreating network "sonar_default" with the default driverCreating sonar_sonarqube_1 ... doneCreating sonar_postgres_1 ... doneliumiaocn:sonar liumiao$
结果确认
docker容器启动之后,可以使用docker-compose ps命令确认服务运行状态
liumiaocn:sonar liumiao$ docker-compose -f docker-compose.7.9.1.yml ps Name Command State Ports ----------------------------------------------------------------------------------sonar_postgres_1 docker-entrypoint.sh postgres Up 5432/tcp sonar_sonarqube_1 ./bin/run.sh Up 0.0.0.0:9000->9000/tcpliumiaocn:sonar liumiao$
执行示例
这里以Angular的demo应用为例,使用Sonar-Scanner进行扫描,此处使用的Sonar-Scanner的版本为4.2,Java版本为 JDK8,可以看到已经提示在SonarQube 8之后Sonar-Scanner也将会要求使用Java 11 或者以上版本。
执行日志示例
/data/jenkins/workspace/angular-pipeline-job/demo # /usr/local/share/sonar/bin/sonar-scanner '-Dsonar.projectKey=demo' '-Dsonar.sources=src' '-Dsonar.host.url=http://192.168.31.242:9000' '-Dsonar.login=admin' '-Dsonar.password=admin'INFO: Scanner configuration file: /usr/local/share/sonar/conf/sonar-scanner.propertiesINFO: Project root configuration file: NONEINFO: SonarQube Scanner 4.2.0.1873INFO: Java 1.8.0_212 IcedTea (64-bit)INFO: Linux 4.9.87-linuxkit-aufs amd64INFO: User cache: /root/.sonar/cacheINFO: SonarQube server 7.9.1INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)WARN: SonarScanner will require Java 11+ to run starting in SonarQube 8.xINFO: Load global settingsINFO: Load global settings (done) | time=687msINFO: Server id: 46AF5D23-AW3zxFXCfmhe-zhloQSgINFO: User cache: /root/.sonar/cacheINFO: Load/download pluginsINFO: Load plugins indexINFO: Load plugins index (done) | time=449msINFO: Load/download plugins (done) | time=1523msINFO: Process project propertiesINFO: Project key: demoINFO: Base dir: /data/jenkins/workspace/angular-pipeline-job/demoINFO: Working dir: /data/jenkins/workspace/angular-pipeline-job/demo/.scannerworkINFO: Load project settings for component key: 'demo'INFO: Load quality profilesINFO: Load quality profiles (done) | time=840msINFO: Load active rulesINFO: Load active rules (done) | time=1773msWARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.INFO: Indexing files...INFO: Project configuration:INFO: 13 files indexedINFO: Quality profile for ts: Sonar wayINFO: ------------- Run sensors on module demoINFO: Load metrics repositoryINFO: Load metrics repository (done) | time=389msINFO: Sensor SonarTS [typescript]INFO: Load project repositoriesINFO: Load project repositories (done) | time=332msINFO: Analyzing 8 typescript file(s) with the following configuration file /data/jenkins/workspace/angular-pipeline-job/demo/tsconfig.jsonINFO: 8 files analyzed out of 8INFO: Sensor SonarTS [typescript] (done) | time=14007msINFO: ------------- Run sensors on projectINFO: Sensor Zero Coverage SensorINFO: Sensor Zero Coverage Sensor (done) | time=49msINFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.INFO: 5 files had no CPD blocksINFO: Calculating CPD for 3 filesINFO: CPD calculation finishedINFO: Analysis report generated in 183ms, dir size=20 KBINFO: Analysis report compressed in 1412ms, zip size=13 KBINFO: Analysis report uploaded in 2278msINFO: ANALYSIS SUCCESSFUL, you can browse http://192.168.31.242:9000/dashboard?id=demoINFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis reportINFO: More about the report processing at http://192.168.31.242:9000/api/ce/task?id=AW31c1LgGJZg-xbI0uFyINFO: Analysis total time: 23.985 sINFO: ------------------------------------------------------------------------INFO: EXECUTION SUCCESSINFO: ------------------------------------------------------------------------INFO: Total time: 28.369sINFO: Final Memory: 9M/63MINFO: ------------------------------------------------------------------------/data/jenkins/workspace/angular-pipeline-job/demo #
执行结果示例
转载地址:https://liumiaocn.blog.csdn.net/article/details/102691703 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年05月01日 22时27分50秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
COMP7404 Machine Learing——KNN
2019-04-30
COMP7404 Machine Learing——SVM
2019-04-30
COMP7404 Machine Learing——ROC
2019-04-30
Python量子计算qiskit
2019-04-30
Python的多线程不是真的多线程(GIL全局解释器锁)
2019-04-30
Python手动读取MNIST数据集
2019-04-30
Python手动读取CIFAR-10数据集
2019-04-30
Pytorch(十一) —— 分布式(多GPU)训练
2019-04-30
Deeplab v3
2019-04-30
tensor/矩阵/图片等更换通道,调整size
2019-04-30
本地和colab 中 改变tensorflow的版本
2019-04-30
CUB-200鸟类数据集
2019-04-30
Python反射机制
2019-04-30
YAPF —— Python代码格式化工具
2019-04-30