Help me figure out why PR decoration doesn't work

Good day.

Versions:

  • SonarQube Scanner 4.2.0.1873
  • Developer Edition Version 8.1 (build 31237)
  • Linux 5.3.0-40-generic amd64

We are trying to implement PR decoration in our proyect following https://docs.sonarqube.org/latest/analysis/pr-decoration . However we are encounting a message like this: Pull request decoration did not happen. Please configure pull request properties in the project administration.

We are using gitlab-ci version 12.7.1 using shell configuration to use both, sonarqube and scanner in a server (locally) and the repository is remote. Also created a gitlab user and obtained the user token with api access. with token we configured PR decoration tab in the left sonarqube’s panel in Gitlab tab.

Our CI Job is the following:

sonarqube-check:
    variables:
        SONAR_TOKEN: "****************************************"
        SONAR_HOST_URL: "http://localhost:2294"
        GIT_DEPTH: 0
    stage: QA
    script:
        - npm install
        - sonar-scanner
    allow_failure: false
    only:
        - merge_requests
        - Development
    tags:
        - sonarqube

we obtained token from sonarqube in account security options.

sonar-scanner.properties are:

sonar.host.url=http://localhost:2294
sonar.sourceEncoding=UTF-8
sonar.projectKey=FCMovil
sonar.sources=src

Thanks for your help.

Hi,
Could you please check your logs (<sonarqube_install>/logs/ce.log>) and see if there is anything relevant?
If I understood correctly, you are using a self managed GitLab CI/CD and code repository?

Hi, i will check later because im not currently on PC. Im using self managed gitlab CI/CD (dedicated runner on the machine using shell) but using a remote repository (gitlab.com) not self managed.

Hi, this is the log file, i didn’t found anything related to errors.

ce.log.txt (36.2 KB)

Also added some screenshoots:

Merge request:

Results in Sonarqube.

Gitlab CI Log

GitlabCi log.txt (9.9 KB)

The src directory that we configured is composed by the next type of files:

  • Typescript
  • CSS
  • HTML

thanks for your answer.

At least the warning should be in the logs. Any chance it got rotated and is in another file?

Based on your setup, my guess is that the scanner running in your self hosted CI is not picking up the correct address for gitlab.com.

I will check other logs related to sonarqube and gitlab-runner to check if there is something that im missing about an error. I will keep you updated.

@dmeneses checked all logs that i found and only encountered this, also i didn’t configure logs outputs so that is default:

Gitlab ci log

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/home/gitlab-runner/.sonar/cache/a89f1943fc75b65becd9fb4ecab8d913/sonar-tsql-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

es.log

2020.02.20 10:38:10 WARN  es[][o.e.d.c.s.Settings] [http.enabled] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.

web.log

2020.02.20 10:38:24 WARN  web[][o.s.s.a.LogOAuthWarning] For security reasons, OAuth authentication should use HTTPS. You should set the property 'Administration > Configuration > Server base URL' to a HTTPS URL.
2020.02.20 10:38:24 WARN  web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/plugins/download
2020.02.20 10:38:24 WARN  web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/permissions/search_templates
2020.02.20 10:38:24 WARN  web[][o.s.a.s.w.WebService$Action] The response example is not set on action api/support/info

sonar.log

Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
ERROR: [2] bootstrap checks failed

didn’t found any warning or errror in ce.log.

Thanks for your help

SonarQube needs a GitLab user to decorate the merge requests. Did you:

  • Generate an access token for the GitLab user with scope “API” activated?
  • Grant “reporter” permission to the GitLab user for the project where merge requests are performed

In SonarQube, did you:

  • Create a “Merge Request Decoration configuration” under (Global-) Administration->Pull Request Decoration-> GitLab?
  • For the SonarQube project itself, did you select the above configuration in (Project-) Administration → General Settings → Pull Request Decoration

If all yes, can you see the analysis of the Merge Request in SonarQube (Project-) Administration → Branches & Pull Request → Pull Requests ?
Any network issues between the 2 servers (e.g. a Firewall)?

Hello.

I disabled firewall and did the other steps before and didn’t work. I will try later on another network to see what happens.

Thanks for your help.

I’ve struggled with PR decoration on Github for quite a while. We had just the message that you also see “Pull request decoration did not happen…”.
The reason in the end was that our .git folder was not present during the scan and Sonar refused to create PR decorations despite all required settings where made. I think this is a undocumented requirement.

1 Like

I have same issue. SonarQube seems to be configured (GitLab url and token provided). sonar-scanner finished with no errors, analysis on server side as well. Some issues are found in code but PR is not decorated. That’s the only warning I get “Pull request decoration did not happen. Please configure pull request properties in the project administration.”

Last comment doesn’t help cause in my case .git folder is in place. SonarQube logs also don’t contain any error/warning messages that could help me debug it. What else could I do to figure it out?

Hi,
Did you pick your GitLab configuration in the Pull Request Decoration settings? Is your build running in GitLab’s CI?

If project’s settings -> pull request decoration I have configuration chosen and project id empty. Yes, I’m using GitLab’s CI. Scanner is running fine and is able to send results to SonarQube.

Last analysis is still running (for 4 hours now) but that could be unrelated issue. Update: it got somehow canceled after 12h 20m of runtime.

The error message indicates that while processing the analysis, SonarQube did not find the P/R decoration settings for that project.
Could you try getting <SONARQUBE_URL>/api/alm_settings/get_binding?project=<project_key> ?

1 Like

You right. That configuration option was missing. Maybe I forgot to click “Save”. Thanks for your help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.