--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD9wyxEpf977L%3DxpzxaBZ0qMqOPO2CDQDEym7ue8MUGimhM2sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. If you are not using the 'withSonarQubeEnv' wrapper to run your analysis, you have to pass the attributes manually to this step.
at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.processStepParameters(WaitForQualityGateStep.java:127)
at org.sonarsource.scanner.jenkins.pipeline.WaitForQualityGateStep$Execution.start(WaitForQualityGateStep.java:107)
stage('sonar-build') {
steps { script { withSonarQubeEnv('VantageSonar') {
sh 'mvn clean package sonar:sonar'
def qg = waitForQualityGate() if (qg.status != 'OK') { error "Pipeline aborted due to quality gate failure: ${qg.status}" } } } }
}Enter code here...
api/webhooks/deliveries result:
{"deliveries":[{"id":"AVqQTJiMvUKPnZt1PZie","componentKey":"com.mycompany:web-app","ceTaskId":"AVqQTI00uNSR7Z9AqVMA","name":"Jenkins
ATI","url":"http://jenkins.mycompany.com:8080/jenkins/sonarqube-webhook/","at":"2017-03-02T19:33:43+0100","success":false,"httpStatus":403,"durationMs":7}]}
api/webhooks/delivery result:
{"delivery":{"id":"AVqQTJiMvUKPnZt1PZie","componentKey":"com.mycompany:web-app","ceTaskId":"AVqQTI00uNSR7Z9AqVMA","name":"Jenkins
ATI","url":"http://jenkins.mycompany.com:8080/jenkins/sonarqube-webhook/","at":"2017-03-02T19:33:43+0100","success":false,"httpStatus":403,"durationMs":7,"payload":"{\"taskId\":\"AVqQTI00uNSR7Z9AqVMA\",\"status\":\"SUCCESS\",\"analysedAt\":\"2017-03-02T19:33:34+0100\",\"project\":{\"key\":\"com.mycompany:web-app\",\"name\":\"com.mycompany:web-app\"},\"qualityGate\":{\"name\":\"SonarQube
way\",\"status\":\"OK\",\"conditions\":[{\"metric\":\"new_security_rating\",\"operator\":\"GREATER_THAN\",\"value\":\"1\",\"status\":\"OK\",\"onLeakPeriod\":true,\"errorThreshold\":\"1\"},{\"metric\":\"new_reliability_rating\",\"operator\":\"GREATER_THAN\",\"value\":\"1\",\"status\":\"OK\",\"onLeakPeriod\":true,\"errorThreshold\":\"1\"},{\"metric\":\"new_maintainability_rating\",\"operator\":\"GREATER_THAN\",\"value\":\"1\",\"status\":\"OK\",\"onLeakPeriod\":true,\"errorThreshold\":\"1\"},{\"metric\":\"new_coverage\",\"operator\":\"LESS_THAN\",\"status\":\"NO_VALUE\",\"onLeakPeriod\":true,\"errorThreshold\":\"80\"}]},\"properties\":{}}"}}
Hi Julien,this feature is nice but it has been easily possible to achieve the same with https://github.com/SonarQubeCommunity/sonar-build-breaker
A lot more important would be the long-standing issue https://jira.sonarsource.com/browse/SONAR-6763 - any news when quality gates on incremental (or if not incremental, at least on "non-server-side-saving") sonar runs will be possible?
*Should* the waitForQualityGate be outside a node, or *must* it be outside of a node? We have some existing scripts which use a single node scope for the whole script, and would like to integrate the quality gate with minimal changes. The extra wait time is no issue at the moment.
We also have the "Unable to get task id" issue, not sure whether this is related? It's also not clear to me yet how I should start debugging it (I'm looking at the Java code of the plugin, but I'm not sure how many structures I can access in my Jenkinsfile to print their values, e.g. to get the SonarAnalysisAction).Regards,Jan Fabry
stage ("SonarQube analysis") {
steps {
script {
STAGE_NAME = "SonarQube analysis"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, don't analyze."
}
else { // this is a PR build, run sonar analysis
withSonarQubeEnv("SonarGate") {
sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"
}
}
}
}
}
stage ("SonarQube Gatekeeper") {
steps {
script {
STAGE_NAME = "SonarQube Gatekeeper"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, skip."
}
else { // this is a PR build, fail on threshold spill
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
}
}
stage ("SonarQube analysis") {
STAGE_NAME = "SonarQube analysis"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, don't analyze."
}
else { // this is a PR build, run sonar analysis
withSonarQubeEnv("SonarGate") {
sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"
}
}
}
stage ("SonarQube Gatekeeper") {
STAGE_NAME = "SonarQube Gatekeeper"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, skip."
}
else { // this is a PR build, fail on threshold spill
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/7so6S2mAhzg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/20c139a7-1e33-48d0-a9ae-ca5512f28785%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD9wyxENJfUfUhgkNL9hCLXtgig8%2B%2BBQfrcKqiwMsRFu_FXErQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAJp9yiNOAFmHvEZ5i4jWzA1ciiuTKJQfR%3Da79-PnBt6h4M2aqA%40mail.gmail.com.
On Tue, Mar 21, 2017 at 8:40 AM, Julien HENRY
<julien...@sonarsource.com> wrote:
> script {
Should not be necessary AFAIK—you can use block-scoped steps like
`withSonarQubeEnv`.
> withEnv(["JAVA_HOME=${ tool '8u121' }", "PATH+MAVEN=${tool '3.3.9'}/bin:${env.JAVA_HOME}/bin"]) {
`tools` section
> script {
> def qg = waitForQualityGate()
> if (qg.status != 'OK') {
> error "Pipeline aborted due to quality gate failure: ${qg.status}"
This part is not Declarative-friendly. You could add an option to
`waitForQualityGate` to set the build result to `UNSTABLE`.
Let me know if you want any other tests.
This does not work if you run it on a slave. If I change the "agent
any" to "agent { label: "some-slave" }", then it fails for me. My
setup has one master (Linux) and one slave (macOS). Both can reach the
SonarQube server. The badge in the build history does link to the
SonarQube project, so that part is parsed successfully.
Hello Julien,Is it possible that this only works for Maven projects?I was able to run your example, and then I tried the Spring Boot "Getting started" example (from https://github.com/spring-guides/gs-spring-boot/tree/master/complete). If I build it via Maven it works, if I do it via Gradle it doesn't.I tried it on Jenkins 2.48 and Jenkins 2.51, with SonarQube Scanner plugin 2.6. I tested this with a multibranch project, with the Jenkinsfile in the repository. If you want to try it yourself you have to change the complete/build.gradle file to include the SonarQube plugin.This was my Jenkinsfile (Gradle version):#!groovy
Let me know if you want any other tests.
Regards,Jan Fabry
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/20c139a7-1e33-48d0-a9ae-ca5512f28785%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/7so6S2mAhzg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAD9wyxENJfUfUhgkNL9hCLXtgig8%2B%2BBQfrcKqiwMsRFu_FXErQ%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/7so6S2mAhzg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAJp9yiNOAFmHvEZ5i4jWzA1ciiuTKJQfR%3Da79-PnBt6h4M2aqA%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/z_K_wz_8Vw8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/CAD9wyxEf%2BR_tbPQwfCUYnrw8DW5ftePsfsP%2B5QLzEXSW4z4nuA%40mail.gmail.com.
(but it's not always clear to me which
ones actually do that, and since which version)
stage ("SonarQube analysis") {
steps {
script {
withSonarQubeEnv('SonarQube') {
sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"
}
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
}
java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. Please use the 'withSonarQubeEnv' wrapper to run your analysis.
INFO: ANALYSIS SUCCESSFUL, you can browse http://****:9000/sonarqube/dashboard/index/cert-mgmt-dashboard
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://****:9000/sonarqube/api/ce/task?id=AVr1S35oyohgD3UCfaIt
{"task":{"organization":"default-organization","id":"AVr1S35oyohgD3UCfaIt","type":"REPORT","componentId":"AVrnCD3cyohgD3UCfaG0","componentKey":"****","componentName":"****","componentQualifier":"TRK","analysisId":"AVr1S4EhtEGQbCizBv8A","status":"SUCCESS","submittedAt":"2017-03-22T11:14:09+0200","submitterLogin":"****","startedAt":"2017-03-22T11:14:10+0200","executedAt":"2017-03-22T11:14:11+0200","executionTimeMs":473,"logs":false,"hasScannerContext":true}}
--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/7so6S2mAhzg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/9fe415f6-4f2c-435f-b77c-8158082818e5%40googlegroups.com.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/6415f21e-3570-4440-b043-0192746d59fa%40googlegroups.com.