jenkinsci / sonar-gerrit-plugin

Jenkins plugin for posting SonarQube issues as Gerrit review comments
https://plugins.jenkins.io/sonar-gerrit/
MIT License
27 stars 38 forks source link

Sonar-gerrit jenkins plugin doesn't leave a correct comment #129

Closed ranyan713 closed 1 year ago

ranyan713 commented 1 year ago

Jenkins and plugins versions report

Jenkins: 2.361.4 OS: Linux - 5.4.0-131-generic

PrioritySorter:4.1.0 ace-editor:1.1 analysis-model-api:10.16.1 ant:475.vf34069fef73c antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-138.v4e7d9a_7b_a_e61 artifactory:3.17.0 authentication-tokens:1.4 blueocean:1.25.8 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.25.8 blueocean-commons:1.25.8 blueocean-config:1.25.8 blueocean-core-js:1.25.8 blueocean-dashboard:1.25.8 blueocean-display-url:2.4.1 blueocean-events:1.25.8 blueocean-git-pipeline:1.25.8 blueocean-github-pipeline:1.25.8 blueocean-i18n:1.25.8 blueocean-jira:1.25.8 blueocean-jwt:1.25.8 blueocean-personalization:1.25.8 blueocean-pipeline-api-impl:1.25.8 blueocean-pipeline-editor:1.25.8 blueocean-pipeline-scm-api:1.25.8 blueocean-rest:1.25.8 blueocean-rest-impl:1.25.8 blueocean-web:1.25.8 bootstrap4-api:4.6.0-5 bootstrap5-api:5.2.0-3 bouncycastle-api:2.26 branch-api:2.1046.v0ca_37783ecc5 build-failure-analyzer:2.4.0 build-monitor-plugin:1.13+build.202205140447 build-name-setter:2.2.0 build-timeout:1.24 build-user-vars-plugin:1.8 caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.7.5 cloudbees-bitbucket-branch-source:791.vb_eea_a_476405b cloudbees-folder:6.740.ve4f4ffa_dea_54 cobertura:1.17 code-coverage-api:3.1.0 command-launcher:84.v4a97f2027398 commons-lang3-api:3.12.0-36.vd97de6465d5b conditional-buildstep:1.4.2 config-file-provider:3.11.1 configuration-as-code:1512.vb_79d418d5fc8 copyartifact:1.47 credentials:1143.vb_e8b_b_ceee347 credentials-binding:523.vd859a_4b_122e6 dark-theme:262.v0202a_4c8fb_6a dashboard-view:2.447.vda_124dd35f11 data-tables-api:1.12.1-3 display-url-api:2.3.6 docker-commons:1.21 docker-workflow:521.v1a_a_dd2073b_2e durable-task:500.v8927d9fd99d8 echarts-api:5.3.3-1 envinject:2.875.v9b_9e962da_a_ec envinject-api:1.199.v3ce31253ed13 external-monitor-job:192.ve979ca_8b_3ccd favorite:2.4.1 flexible-publish:0.16.1 font-awesome-api:6.1.2-1 forensics-api:1.15.1 gerrit-trigger:2.36.0 git:4.11.5 git-client:3.12.0 git-server:1.11 github:1.34.5 github-api:1.303-400.v35c2d8258028 github-branch-source:1695.v88de84e9f6b_9 gradle:1.39.4 groovy:442.v817e6d937d6c handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 hashicorp-vault-plugin:356.ved18810a_b_828 htmlpublisher:1.30 instance-identity:3.1 ionicons-api:24.va_745a_b_a_97fc3 ivy:2.2 jackson2-api:2.13.3-285.vc03c0256d517 jacoco:3.3.2 jakarta-activation-api:2.0.1-1 jakarta-mail-api:2.0.1-1 javadoc:226.v71211feb_e7e9 javax-activation-api:1.2.0-4 javax-mail-api:1.6.2-7 jaxb:2.3.6-1 jdk-tool:55.v1b_32b_6ca_f9ca jenkins-design-language:1.25.8 jersey2-api:2.37-1 jira:3.8 jjwt-api:0.11.5-77.v646c772fddb_0 jnr-posix-api:3.1.15-1 job-dsl:1.81 jobConfigHistory:1176.v1b_4290db_41a_5 jquery-detached:1.2.1 jquery3-api:3.6.0-4 jsch:0.1.55.61.va_e9ee26616e7 junit:1119.1121.vc43d0fc45561 ldap:2.12 leastload:3.0.0 lockable-resources:2.16 log-parser:2.2 mailer:435.v79ef3972b_5c7 matrix-auth:3.1.5 matrix-project:772.v494f19991984 maven-plugin:3.19 metrics:4.2.10-389.v93143621b_050 mina-sshd-api-common:2.9.1-44.v476733c11f82 mina-sshd-api-core:2.9.1-44.v476733c11f82 momentjs:1.1.1 next-build-number:1.8 okhttp-api:4.9.3-108.v0feda04578cf pam-auth:1.10 parameterized-trigger:2.45 pipeline-build-step:2.18 pipeline-graph-analysis:195.v5812d95a_a_2f9 pipeline-groovy-lib:612.v84da_9c54906d pipeline-input-step:449.v77f0e8b_845c4 pipeline-milestone-step:101.vd572fef9d926 pipeline-model-api:2.2114.v2654ca_721309 pipeline-model-definition:2.2114.v2654ca_721309 pipeline-model-extensions:2.2114.v2654ca_721309 pipeline-rest-api:2.24 pipeline-stage-step:296.v5f6908f017a_5 pipeline-stage-tags-metadata:2.2114.v2654ca_721309 pipeline-stage-view:2.24 plain-credentials:139.ved2b_9cf7587b plot:2.1.11 plugin-util-api:2.17.0 popper-api:1.16.1-3 popper2-api:2.11.6-1 postbuildscript:3.1.0-375.v3db_cd92485e1 prism-api:1.28.0-2 pubsub-light:1.16 resource-disposer:0.20 run-condition:1.5 saml:2.333.vc81e525974a_c scm-api:621.vda_a_b_055e58f7 script-security:1175.v4b_d517d6db_f0 snakeyaml-api:1.31-84.ve43da_fb_49d0b sonar:2.14 sonar-gerrit:377.v8f3808963dc5 sse-gateway:1.25 ssh-agent:295.v9ca_a_1c7cc3aa ssh-credentials:305.v8f4381501156 ssh-slaves:1.834.v622da_57f702c sshd:3.242.va_db_9da_b_26a_c3 structs:324.va_f5d6774f3a_d theme-manager:1.5 throttle-concurrents:2.9 timestamper:1.20 token-macro:308.v4f2b_ed62b_b_16 trilead-api:1.67.vc3938a_35172f variant:59.vf075fe829ccb versioncolumn:2.2 warnings-ng:9.19.2 windows-slaves:1.8.1 workflow-aggregator:590.v6a_d052e5a_a_b_5 workflow-api:1192.v2d0deb_19d212 workflow-basic-steps:994.vd57e3ca_46d24 workflow-cps:2759.v87459c4eeaca workflow-durable-task-step:1199.v02b_9244f8064 workflow-job:1207.ve6191ff089f8 workflow-multibranch:716.vc692ae52371b workflow-scm-step:400.v6b_89a1317c9a workflow-step-api:639.v6eca_cd8c04aa workflow-support:838.va_3a_087b_4055b ws-cleanup:0.43

What Operating System are you using (both controller, and any agents involved in the problem)?

Jenkins: 2.361.4 Sonar Gerrit plug-in Version: 377.v8f3808963dc5 Sonar Qube Community Edition Version 8.9.8 (build 54436)

Trying to get SonarQube feedback via Gerrit Code Review. gerrit triggers jenkins job when a commit is pushed and jenkins job triggers SonarQube running with Pull Request analysis strategy. We can see the report with the given url for example, https://{sonar_url}/dashboard?id={project.key}&{sonar.pullrequest.key}

However, the report is not getting reported to gerrit with a comment. We used to use 7.6 SonarQube version with preview mode with 2.4.3 sonar gerrit plug-in which worked fine.

Do we have a known issue with sonar-gerrit plugin?

Thanks,

Reproduction steps

commit gerrit commit it triggers Jenkins sonar job SonarQube is runnig SonarQube report is available in web UI with violations Post-build Actions with 'PostSonarQube issues as Gerrit comments' and 'Score Settings' are configured correctly

Expected Results

Violations should be match and reported in gerrit comments ex) 11 SonarQube violations have been found.

Actual Results

No violation is commented in gerrit although (SonarQube violations have not been found.)

Anything else?

We used to use 7.6 SonarQube version with preview mode with 2.4.3 sonar gerrit plug-in which worked fine.

xinatai commented 1 year ago

Environment: Jenkins: 2.361.4 Sonar Gerrit plug-in Version: 377.v8f3808963dc5 Sonar Qube Community Edition Version 8.9.9 (build 56886) with Community Branch Plugin

Trying to get SonarQube feedback via Gerrit Code Review. gerrit triggers jenkins job when a commit is pushed and jenkins job triggers SonarQube running with Pull Request analysis strategy.

I have also this issue block me, the pipeline message says like below: SonarQube report 'xxx/target/sonar/sonar-report.json' does not exist. Please check plugin settings No SonarQube report available. Please check your Project Settings

Is any workaround for it? Thanks advance.

reda-alaoui commented 1 year ago

Your job configurations are probably incorrect. At least, provide your exact job configurations (gradle or xml).

ranyan713 commented 1 year ago

Thanks, @reda-alaoui.

Here is the link for configOutput.xml and gerrit-trigger.xml

https://drive.google.com/file/d/1Uc4Fkatf5Yo2_y4fS6iiTUfEzoG57WOL/view?usp=share_link https://drive.google.com/file/d/1TpSQy12AJPIV1XBawVIWU8jX_F7OtOyQ/view?usp=share_link

Again, pull request fails Sonar gates, but reports success to Gerrit.

14:23:14 BUILD SUCCESSFUL in 6m 14s 14:23:14 4275 actionable tasks: 1188 executed, 3087 from cache 14:23:14 Build step 'Invoke Gradle script' changed build result to SUCCESS 14:23:21 SonarQube task 'AYYTlUBM6tSW1R5ccEDH' is in progress. 14:23:21 Waiting PT5S before re-checking SonarQube task 'AYYTlUBM6tSW1R5ccEDH' status ... 14:23:26 SonarQube task 'AYYTlUBM6tSW1R5ccEDH' is in progress. 14:23:26 Waiting PT5S before re-checking SonarQube task 'AYYTlUBM6tSW1R5ccEDH' status ... 14:23:31 SonarQube task 'AYYTlUBM6tSW1R5ccEDH' is in progress. 14:23:31 Waiting PT5S before re-checking SonarQube task 'AYYTlUBM6tSW1R5ccEDH' status ... 14:23:36 SonarQube task 'AYYTlUBM6tSW1R5ccEDH' is in progress. 14:23:36 Waiting PT5S before re-checking SonarQube task 'AYYTlUBM6tSW1R5ccEDH' status ... 14:23:41 SonarQube task 'AYYTlUBM6tSW1R5ccEDH' is in progress. 14:23:41 Waiting PT5S before re-checking SonarQube task 'AYYTlUBM6tSW1R5ccEDH' status ... 14:23:46 SonarQube task 'AYYTlUBM6tSW1R5ccEDH' completed. 14:23:46 Issues to be commented: 0 14:23:46 Issues to be involved in score calculation: 0 14:23:46 Review has been sent 14:23:47 Finished: SUCCESS

and below is the result from Sonar Gerrit 2.4.6 with SonarQube 7.6 (preview mode of course)

19:28:13 BUILD SUCCESSFUL in 19m 57s 19:28:13 4195 actionable tasks: 1219 executed, 2976 from cache 19:28:14 Build step 'Invoke Gradle script' changed build result to SUCCESS 19:28:14 Archiving artifacts 19:28:14 Getting Sonar Report from: /mnt/jenkins/workspace/AndroidMC-Sonar-Preflight/build/sonar/sonar-report.json 19:28:14 Report has loaded and contains 1914 issues 19:28:15 Issues to be commented: 11 19:28:15 Issues to be involved in score calculation: 11 19:28:15 Review has been sent 19:28:16 [WS-CLEANUP] Deleting project workspace... 19:28:16 [WS-CLEANUP] Deferred wipeout is used... 19:28:16 [WS-CLEANUP] done 19:28:16 Finished: SUCCESS

Thanks!