SonarQube集成Jenkins平台搭建

SonarQube平台搭建

一、项目搭建的必要条件

二、搭建SonarQube

  • 安装教程见官网:Install the server

  • 修改sonar.properties

    sonar.jdbc.username=sonar
    sonar.jdbc.password=sonar
    sonar.jdbc.url=jdbc:postgresql://localhost/sonar?currentSchema=public sonar.web.port=9090

  • 插件汉化 方式一:登录SonarQube平台,在配置-->应用市场-->搜索Chinese Pack进行安装 方式二:下载对应jar包,放在<SONARQUBE_HOME>/extensions/plugins里面 插件市场地址:SonarQube™ Plugins Index ;针对与java的pmd-p3c插件地址:GitHub - caowenliang/sonar-pmd-p3c: sonarQube 整合 阿里p3c

三、ScanSonarScanner配置

  • 下载地址:SonarScanner

  • 配置环境变量:

    vi /etc/profile
    #SonarScanner
    export Sonar_Home=/opt/SonarScanner/
    export PATH=Sonar_Home/bin:PATH
    source /etc/profile

  • 修改 配置sonar-scanner.properties:

    #----- Default SonarQube server
    sonar.host.url=http://localhost:9090
    #----- Default source code encoding
    sonar.sourceEncoding=UTF-8

四、集成Jenkins

  • 下载ScanSonarScanner插件(插件市场搜索SonarScanner for Jenkins),重启Jenkins

  • 服务配置:Manage Jenkins > Configure System>SonarQube servers

  • 客户端配置:Manage Jenkins > Tools>SonarQube Scanner

  • 构建配置:Configure>Build Steps

  • Analysis properties 参数内容解释:

    #projectKey:项目唯一标识 projectName:项目名称 二个名字一样即可
    sonar.projectKey=iflb-web-166
    sonar.projectName=iflb-web-166
    #分析的路径 相对路径在jenkins是相对于workspace来说的
    sonar.sources=src_bak
    #登录sonarqube凭证
    sonar.login=acd76918c4eab666433c2783c073d2ddf52e120d
    sonar.nodejs.executable=/home/worker/tools/node-v10.15.3-linux-x64/bin/node
    #Java编译后的文件目录
    sonar.java.binaries=target/classes
    #只解析java语言
    sonar.language=java

相关推荐
Li-Yongjun6 分钟前
Linux 内核等待队列(Wait Queue)
linux·运维·windows
humors22117 分钟前
Windows运维与安全场景合集(不定期更新)
大数据·运维·服务器·程序人生·网络安全
SAP上海工博云署17 分钟前
2026年中小企业SAP服务商选型技术解析
大数据·运维·数据库·人工智能·信息可视化·运维开发·信息与通信
WXDcsdn18 分钟前
联想服务器使用RAID卡组建RAID(企业服务器解决方案)
运维·服务器
jimy121 分钟前
Linux动态加载器,loader,dynamic linker
linux·运维·服务器
三十..22 分钟前
华为云全栈:网络/存储/运维高能实战
运维·华为云
lolo大魔王26 分钟前
Linux 文件权限超详细详解(读懂权限标识、数字权限、特殊权限、chmod/chown)
linux·运维·服务器
Plastic garden29 分钟前
Docker(3)Docker 镜像 & Dockerfile
运维·docker·容器
console.log('npc')39 分钟前
Windows试用期重置工具,纯官方 / 安全教程
运维·自动化·typora·脚本
Shingmc343 分钟前
【Linux】多路转接之epoll
linux·运维·服务器·开发语言·网络