略
version: "3"
services:
sonar:
image: sonarqube:8.4.2-community
container_name: sonar
hostname: sonar
restart: always
depends_on:
- pgsql
ports:
- 9000:9000
environment:
- SONAR_JDBC_URL=jdbc:postgresql://pgsql:5432/sonarqube?
- SONAR_JDBC_USERNAME=postgres
- SONAR_JDBC_PASSWORD=123456
volumes:
- /data/sonarqube/sonarqube_extensions:/opt/sonarqube/extensions
- /data/sonarqube/sonarqube_logs:/opt/sonarqube/logs
- /data/sonarqube/sonarqube_data:/opt/sonarqube/data
pgsql:
image: postgres:12
container_name: pgsql
hostname: pgsql
restart: always
volumes:
- /data/sonarqube/pgsql/data:/var/lib/postgresql/data
environment:
TZ: Asia/Shanghai
POSTGRES_PASSWORD: 123456
POSTGRES_DB: sonarqube
ports:
- "5432:5432"
logging:
options:
max-size: '100m'
max-file: '10'
下载包:
wget -P /usr/local/sonarscanner https://github.com/SonarSource/sonar-scanner-cli/releases/download/4.4.0.2170/sonar-scanner-cli-4.4.0.2170-linux.zip
unzip sonar-scanner-4.4.0.2170.linux.zip
vim sonar-scanner-4.4.0.2170/conf/sonar-scanner.properties
sonar.host.url=http://192.168.1.162:9000
sonar.sourceEncoding=UTF-8
sonar.projectName=${JOB_NAME} # 项目名称,使用 Jenkins 内置变量 JOB_NAME
sonar.projectKey= # 自定义项目唯一标识
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.sources=${WORKSPACE} # 扫描文件夹
sonar.java.binaries=${WORKSPACE}
sonar.host.url=http://192.168.1.100:9000 # sonar服务端地址
sonar.login= # 创建的项目令牌