文章目录
- 1. 前置条件
- 2. 编写docker-compose-sonar.yml文件
- 3. 集成 gitlab
- 4. Sonar Login with GitLab
1. 前置条件
安装docker-compose
安装docker
创建容器运行的特有网络
创建挂载目录
2. 编写docker-compose-sonar.yml文件
version: "3"
services:sonar-postgres:image: postgres:14.4networks:- gitlabcontainer_name: pgsqlvolumes:- "/data/pgsql/data:/var/lib/postgresql/data"environment:- POSTGRES_USER=sonar- POSTGRES_PASSWORD=sonar@123- TZ=Asia/Shanghaisonarqube:image: sonarqube:8.9-communitycontainer_name: sonarnetworks:- gitlabenvironment:- TZ=Asia/Shanghai- SONARQUBE_JDBC_USERNAME=sonar- SONARQUBE_JDBC_PASSWORD=sonar@123- SONARQUBE_JDBC_URL=jdbc:postgresql://sonar-postgres:5432/sonarvolumes:- "/data/sonar/data:/opt/sonarqube/data"- "/data/sonar/logs:/opt/sonarqube/logs"- "/data/sonar/extensions:/opt/sonarqube/extensions"ports:- "9000:9000"depends_on:- sonar-postgresnetworks:gitlab:driver: bridge
docker-compose -f docker-compose-sonar.yml up -d
3. 集成 gitlab
Administration -> Configuration -> ALM integrations -> GitLab -> **Create configuration
4. Sonar Login with GitLab
参考: https://docs.sonarqube.org/9.7/instance-administration/authentication/gitlab/