我是gradle和声纳qube的新手。我已经在本地安装了声纳管,但是如果主要问题的数量大于50,则需要使gradle构建在本地失败。
/*
build.gradle:
Please note that this file should not be changed except for local build and deployments.
Glpdependencies.gradle and build.gradle will be overwritten from glp-core repo. However, they can be modified
for local testing purposes.
*/
buildscript {
ext {
springBootVersion = '2.0.4.RELEASE'
}
repositories {
mavenLocal()
maven { url "https://plugins.gradle.org/m2/" }
mavenCentral()
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}
// These are gradle build dependencies and not application requirements
dependencies {
classpath 'de.undercouch.download:de.undercouch.download.gradle.plugin:3.4.3'
classpath "net.linguica.gradle:maven-settings-plugin:0.5"
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.14.0"
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:2.0.0.RELEASE"
//classpath 'io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: "org.sonarqube"
sonarqube {
properties {
property "sonar.projectKey", "sum"
property "sonar.buildbreaker.skip" , "false"
}
}
group = 'com.test.sonarqube.gradle'
apply from: 'glpdependencies.gradle'
apply from: 'version.gradle'
Below is my gradle.properties:
//org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_144.
systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.sourceEncoding=UTF-8
systemProp.sonar.forceAuthentication=true
如果我们需要在其他地方进行配置,请告诉我。因为这是一个gradle项目,所以我的本地系统中也安装了声纳qube服务器。
我在声纳qube服务器中遇到问题等类型,但是如果主要问题的数量大于50,则需要在本地使构建失败。
我尝试了很多事情,但是即使添加了属性也没有用
build.gradle中的属性“sonar.buildbreaker.skip”,“false”,但仍无法正常工作
最佳答案
您将无法使Gradle构建失败*,因为它是一个同步过程,而您所说的是Quality Gate的应用,它是一个异步过程。
设置“重大问题> 50”的错误条件的质量门很容易,但是直到后台任务处理结束才计算质量门状态。
一旦在本地运行分析,分析报告将被 bundle 并提交到服务器,在此排队并随后进行异步处理。您可以设置webhook以在处理完成时通知另一个系统。 webhook通知有效负载包括Quality Gate统计信息,但这不会帮助您使Gradle构建失败。
OTOH,配置项构建失败的过程为well-established
*没有很大的困难
关于java - 如果sonarqube中的主要问题数量大于50,要使我们的本地构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53113096/