# MR decoration of scans with results in Gitlab not shown

**URL:** <https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417>\
**Category:** SonarQube Server / Community Build\
**Created:** [August 7, 2022, 6:57am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417 "2022-08-07T06:57:15Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 7, 2022, 6:57am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/1 "2022-08-07T06:57:15Z")

</div>

- Latest K8s \* Developer Edition
- Version 9.5 (build 56709)
- MR decoration of scans with results in Gitlab **not shown**
- Added configuration and Gitlab integration, results added to sonarcube but i dont see MR’s decorated  
gitlab-ci.yml

```auto
sonarqube-check:
  stage: test
  <<: *ci_img
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
    GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script: gradle sonarqube -Dsonar.qualitygate.wait=true
  allow_failure: true

```

build.gradle

```auto
plugins {
  id 'java'
  id 'checkstyle'
  id "org.sonarqube" version "3.4.0.2513"
}

sonarqube {
  properties {
    property "sonar.projectKey", "xxxxxxx"
    property "sonar.qualitygate.wait", true
  }
}

```

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 7, 2022, 7:05am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/2 "2022-08-07T07:05:30Z")

</div>

when running the scan we get this error:

```auto

$ gradle sonarqube -Dsonar.qualitygate.wait=true
Welcome to Gradle 6.8.3!
Here are the highlights of this release:
 - Faster Kotlin DSL script compilation
 - Vendor selection for Java toolchains
 - Convenient execution of tasks in composite builds
 - Consistent dependency resolution
For more details see https://docs.gradle.org/6.8.3/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* Where:
Build file '/builds/prismacloud/iam/pcs-iam-ingestion/build.gradle' line: 18
* What went wrong:
A problem occurred evaluating root project 'prisma-iam-ingestion'.
> No signature of method: build_xxxxxx.sonarqube() is applicable for argument types: (build_xxxxx$_run_closure1) values: [build_xxxxx$_run_closure1@3a931fcd]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [August 8, 2022, 8:19am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/3 "2022-08-08T08:19:17Z")

</div>

The _build.gradle_ you shared is shorter than 18 lines – can you share the full one (at _/builds/prismacloud/iam/pcs-iam-ingestion/build.gradle_)?

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 8, 2022, 1:35pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/4 "2022-08-08T13:35:51Z")

</div>

Hi Colin,

Not sure i can share the whole file will check,  
anyway this is the only relevant code for sonarcube we are using our own image with gradle 6.8.1

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [August 8, 2022, 1:37pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/5 "2022-08-08T13:37:34Z")

</div>

Well since the error is at line 18 of this _build.gradle_ file… it sure seems relevant.

> [@Lior\_Cohen](#):
>
> ```auto
> Build file '/builds/prismacloud/iam/pcs-iam-ingestion/build.gradle' line: 18
> 
> ```

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 8, 2022, 1:43pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/6 "2022-08-08T13:43:59Z")

</div>

Hi here is the beginning of the file including line 18

```auto
buildscript {
  repositories {
    mavenCentral()
    dependencies {
      if(project.hasProperty('sealights')){
        classpath 'io.sealights.on-premise.agents.plugin:sealights-gradle-plugin:3.1.777'
      }
    }
  }
}

plugins {
  id 'java'
  id 'checkstyle'
  id "org.sonarqube" version "3.4.0.2513"
}

sonarqube {
  properties {
    property "sonar.projectKey", "prismacloud_iam_pcs-iam-ingestion_xxxxxxxx"
    property "sonar.qualitygate.wait", true
  }
}

```

line 18 is the sonarqube part

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 9, 2022, 10:35am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/7 "2022-08-09T10:35:38Z")

</div>

Hi i now get the job run successfully but with no mr decoration still:

```auto
sonarqube-check:
  stage: test
  <<: *ci_img
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
    GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - export JAVA_OPTS="-Xmx1024m -XX:+HeapDumpOnOutOfMemoryError"
    - gradle sonarqube -Dsonar.qualitygate.wait==true -Dsonar.qualitygate.timeout=1000
  allow_failure: true
  tags:
    - k8sdev-app
    - eks

```

```auto
> Task :sonarqube
Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
Use of preview features have been detected during analysis. Enable DEBUG mode to see them.
BUILD SUCCESSFUL in 9m 14s
11 actionable tasks: 11 executed
Saving cache for successful job
00:07
Creating cache sonarqube-check-5-non_protected...
.sonar/cache: found 145 matching files and directories 
No URL provided, cache will be not uploaded to shared cache server. Cache will be stored only locally. 
Created cache
Cleaning up project directory and file based variables
00:00
Job succeeded

```

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 11, 2022, 9:13pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/8 "2022-08-11T21:13:02Z")

</div>

Any news on how to proceed  
scans succeed  
we configured it properly so what’s missing for MR decoration ? Help needed

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [August 17, 2022, 3:57pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/9 "2022-08-17T15:57:26Z")

</div>

Hey there.

Can you confirm that the required details are set for [GitLab Integration](https://docs.sonarqube.org/latest/analysis/gitlab-integration/) at the **project-level**? You can check in the project-level **Project Settings \> General Settings \> DevOps Platform Integration**

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 17, 2022, 4:55pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/10 "2022-08-17T16:55:52Z")

</div>

Hi Thanks for the update !

Did everything that is mentioned in the Doc Passed the Env of the SONAR\_TOKEN and the URL variables through the CI  
Also added the app and the scan config to gitlab-ci.yaml  
Configured the global integration and projects were added also.

We are using gitlab runners

In Project setting Devops integration:  
I see we have a Configuration name with the url of the api and i have a project key also when i click test configuration  
i get configuration is valid  
Any suggestions on how we can resolve this issue ?

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 17, 2022, 4:57pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/11 "2022-08-17T16:57:12Z")

</div>

i do have one warning which is:

Shallow clone detected during the analysis. Some files will miss SCM information. This will affect features like auto-assignment of issues. Please configure your build to disable shallow clone.

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 17, 2022, 5:38pm UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/12 "2022-08-17T17:38:49Z")

</div>

Added this took care of the warning:

```auto
variables:
  SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
  GIT_DEPTH: "0"
cache:
  key: "${CI_JOB_NAME}"
  paths:
    - .sonar/cache

```

Latest run passed with no MR decoration

Task :sonarqube  
QUALITY GATE STATUS: PASSED - View details on [https://sonarqube-dev.k8sdev.prismacloud.io/dashboard?id=prismacloud\_iam\_pcs-iam-ingestion\_xxxxxxxx&branch=IVG-5737-sonarqube](https://sonarqube-dev.k8sdev.prismacloud.io/dashboard?id=prismacloud_iam_pcs-iam-ingestion_xxxxxxxx&branch=IVG-5737-sonarqube)  
Analysis total time: 3:00.611 s  
:sonarqube (Thread[Execution worker for ‘:’,5,main]) completed. Took 3 mins 5.494 secs.  
BUILD SUCCESSFUL in 19m 12s  
17 actionable tasks: 17 executed  
Created user preferences directory.  
Saving cache for successful job

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [August 18, 2022, 8:33am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/13 "2022-08-18T08:33:50Z")

</div>

It looks like **branch** analysis was performed, rather than **pull request** (merge request, in GitLab terms) analysis.

> [@Lior\_Cohen](#):
>
> QUALITY GATE STATUS: PASSED - View details on [https://sonarqube-dev.k8sdev.prismacloud.io/dashboard?id=prismacloud\_iam\_pcs-iam-ingestion\_xxxxxxxx&branch=IVG-5737-sonarqube](https://sonarqube-dev.k8sdev.prismacloud.io/dashboard?id=prismacloud_iam_pcs-iam-ingestion_xxxxxxxx&branch=IVG-5737-sonarqube)

Are you running your job on `merge_requests`?

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 18, 2022, 8:50am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/14 "2022-08-18T08:50:52Z")

</div>

we are running on every branch with an MR open:  
I am missing this config in gitlab-ci.yaml

only:

- merge\_requests

because when i added it to the job the job disappeared from the pipeline  
is this the reason it doesn’t work ?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [August 18, 2022, 9:18am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/15 "2022-08-18T09:18:26Z")

</div>

There’s a distinction to be made between branch pipelines and merge request pipelines – you can read about it in this documentation:

> **[Merge request pipelines | GitLab](https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html#use-only-to-add-jobs)**
>
> GitLab product documentation.

And, as the docs state, merge request pipelines:

> - Do not run by default. The jobs in the CI/CD configuration file [must be configured](https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html#prerequisites) to run in merge request pipelines.

---

<div class="post-metadata">

**Author:** ![Lior\_Cohen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lior_cohen/32/20893_2.png) [@Lior\_Cohen](https://community.sonarsource.com/u/Lior_Cohen)\
**Post date:** [August 18, 2022, 9:52am UTC](https://community.sonarsource.com/t/mr-decoration-of-scans-with-results-in-gitlab-not-shown/69417/16 "2022-08-18T09:52:18Z")

</div>

Thanks for the update !  
we use the following to avoid duplication the job still runs on merge request:  
[https://stackoverflow.com/questions/70290807/difference-between-different-gitlab-ci-merge-request-rules](https://stackoverflow.com/questions/70290807/difference-between-different-gitlab-ci-merge-request-rules)

Is this what’s causing the issue ?

```auto
workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: never
    - when: always

```
