sakurayz 2019-06-28
编写 docker-compose.yml
文件
version: '3.3' services: db: image: mysql:5.7.22 restart: always # ports: # - 3306:3306 volumes: - ./mysql/db:/var/lib/mysql - LANG=C.UTF-8 environment: - MYSQL_ROOT_PASSWORD=sonar - MYSQL_DATABASE=sonar - MYSQL_USER=sonar - MYSQL_PASSWORD=sonar command: mysqld --skip-ssl --character_set_server=utf8mb4 --sql_mode="" sonar: restart: always image: sonarqube:alpine depends_on: - db volumes: - ./sonar/data:/opt/sonarqube/data - ./sonar/extensions:/opt/sonarqube/extensions ports: - 9000:9000 - 9092:9092 environment: - SONARQUBE_JDBC_USERNAME=sonar - SONARQUBE_JDBC_PASSWORD=sonar - SONARQUBE_JDBC_URL=jdbc:mysql://db:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
进入 配置 -> 应用市场
下载后放到 /usr/local/bin/sonar-scanner
记得给可执行权限 sudo chmod +x /usr/local/bin/sonar-scanner
sonar.host.url=http://sonar.xxx.xxx sonar.login=b45c1cfb006d1d5c359dxxxxxxx867dfe0f5e91 sonar.sourceEncoding=UTF-8 sonar.modules=javascript-module # sonar.modules=java-module,javascript-module,html-module,css-module # sonar.sources=. # sonar.tests=test # sonar.language=js # sonar.exclusions=test # # Java module # java-module.sonar.projectName=java-module # java-module.sonar.language=java # # .表示projectBaseDir指定的目录 # java-module.sonar.sources=. # java-module.sonar.projectBaseDir=src # sonar.binaries=classes # JavaScript module javascript-module.sonar.projectName=javascript-module javascript-module.sonar.language=js javascript-module.sonar.sources=. javascript-module.sonar.projectBaseDir=app # Html module # html-module.sonar.projectName=html-module # html-module.sonar.language=web # html-module.sonar.sources=. # html-module.sonar.projectBaseDir=web # CSS module # css-module.sonar.projectName=css-module # css-module.sonar.language=css # css-module.sonar.sources=. # css-module.sonar.projectBaseDir=web
stages: - analyze sonar_analyze: stage: analyze script: - ci/sonar_analyze.sh tags: - analyze
#!/bin/bash sonar-scanner \ -Dsonar.analysis.mode=preview \ -Dsonar.projectKey=gitlab:$CI_COMMIT_REF_NAME:$CI_PROJECT_NAME \ -Dsonar.projectName=gitlab:$CI_COMMIT_REF_NAME:$CI_PROJECT_NAME \ -Dsonar.projectVersion=1.0.$CI_PIPELINE_ID \ -Dsonar.issuesReport.html.enable=true \ -Dsonar.gitlab.project_id=$CI_PROJECT_ID \ -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA \ -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME if [ $? -eq 0 ]; then echo "sonarqube code-publish over." fi
© 会煮咖啡的猫咪