jenkins+gradle/maven+sonar+pipline

总结:
gradle配置接入sonar,需要在build.gradle配置中引入sonar插件,而maven不需要。
jenkins pipline maven配置:
stage('SonarQube analysis') {
withSonarQubeEnv('Sonar'){
sh '/usr/local/maven/bin/mvn sonar:sonar -Dsonar.projectName=CTS-capital'
}
}

jenkins pipline gradle配置:(需要修改build.gradle配置)
stage('SonarQube analysis') {
withSonarQubeEnv() {
sh '''
cd mall-page/
/opt/software/gradle-4.8/bin/gradle sonarqube -Dsonar.projectName=MMD-mall-page
'''
}
}

builid.gradle修改如下:第一种需要引入本地包,第二种调用在线网上的包
Using the plugins DSL:

plugins {
id "org.sonarqube" version "2.7.1"
}
Using legacy plugin application:

buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1"
}
}

apply plugin: "org.sonarqube"

上一篇:SonarQube之——安装完后出现SonarQube is under maintenance. Please check back later.


下一篇:javascript – 如何更改Karma执行的LCOV报告的格式?