Gitlab Merge Request Analysis has no code

Must-share information (formatted with Markdown):

Analysis is running for the branches/merge requests and the pull request decoration in gitlab works.

But the Page in sonar is empty and no code is shown:

Jenkins Settings:


        stage('git') {
           git credentialsId: '6d936a5f-ca5b-428a-a33a-44402899e4f9', url:       ''
    lock(quantity: 1, resource: 'sonar-paussb') {
        stage('SonarQube Scan') {
              withSonarQubeEnv('Sonar-DevEdition') {
                  withMaven(jdk: 'amazon-coretto-jdk8-latest', maven: 'Apache Maven latest', options:       [artifactsPublisher(disabled: true)]) {
                    bat 'mvn -P coverage -Djavafx.verbose=true -Dprism.verbose=true       -Djavax.persistence.jdbc.server=paussb-jenkins-sonar -Dmaven.test.failure.ignore=true clean verify sonar:sonar'
                  } // SonarQube taskId is automatically attached to the pipeline context

From the Log:

[INFO] ------------- Run sensors on project
[INFO] Sensor Zero Coverage Sensor
[INFO] Sensor Zero Coverage Sensor (done) | time=78ms
[INFO] Sensor Java CPD Block Indexer
[INFO] Sensor Java CPD Block Indexer (done) | time=2384ms
[INFO] CPD Executor 723 files had no CPD blocks
[INFO] CPD Executor Calculating CPD for 2551 files
[INFO] CPD Executor CPD calculation finished (done) | time=1135ms
[INFO] SCM writing changed lines
[INFO] SCM writing changed lines (done) | time=12ms
[INFO] Analysis report generated in 1416ms, dir size=3 MB
[INFO] Analysis report compressed in 3079ms, zip size=3 MB
[INFO] Analysis report uploaded in 411ms
[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
[INFO] Analysis total time: 9:58.943 s

The Problem here was, that the git checkout always checked out the master

To checkout the pull request the following has to be done

checkout([$class: 'GitSCM', branches: [[name: '*/${CHANGE_BRANCH}']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', noTags: false, reference: '', shallow: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '6d936a5f', url: 'git@gitlab']]])

the branches has to bet set to:

  branches: [[name: '*/${CHANGE_BRANCH}']], 

BRANCH_NAME was not working in my case with gitlab, because this variable reported a non exitent branch. This Variable contains the NAME of the MR.

Glad you found what was the problem - thanks for posting.

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