Scanning ansible playbooks stored in github, but getting error on sonarqube no line of code

Hi Team,

Sonarqube version: 9.9.2.77730-enterprise

I am having ansible playbooks stored in github and I want to scan them and get a report on the sonarqube. To do this I am executing jenkins pipeline, which is having jenkinsfile as below:

pipeline{ 
//	    agent any
	      agent {
    kubernetes {
      inheritFrom "ci-executor"
    }
  }
            
        stages{
            stage ('Download Artifacts'){
                steps{
		    container("build-agent") {
                  // Download SonarScanner from Artifactory
                sh 'curl -X GET https://artifactory.org.com/artifactory/test/sonar-scanner-cli-4.7.0.2747.tar.gz -O'
			   	sh 'tar -xzvf sonar-scanner-cli-4.7.0.2747.tar.gz -C .'
				sh 'rm -rf sonar-scanner-cli-4.7.0.2747.tar.gz'
				
								
			}
			}
			}
			
	stage('Sonar Analysis') {
                steps {
			    container("build-agent") {	
		    withCredentials([string(credentialsId: "jenkins-sonarqube-key", variable: "SONARQUBE_API_KEY")]) {
			
			sh "sonar-scanner-4.7.0.2747/bin/sonar-scanner -X -Dsonar.login=sqa_b8a59fbkkk6ee269f80743f941f8694ccab9de00c7a -Dsonar.projectKey=ansible-model-repo -Dsonar.host.url=https://sonarqube.org.com/"
		    }
                }
            }
	    }
        
        }
	}

The logs from the pipeline is :

15:16:20.462 INFO: Sensor Analysis Warnings import [csharp] (done) | time=1ms
15:16:20.463 INFO: Sensor Zero Coverage Sensor
15:16:20.470 INFO: Sensor Zero Coverage Sensor (done) | time=6ms
15:16:20.475 INFO: CPD Executor Calculating CPD for 0 files
15:16:20.476 INFO: CPD Executor CPD calculation finished (done) | time=0ms
15:16:20.497 DEBUG: SCM revision ID '70f7f2dc096a62c93835b541a494cd34cc360c78'
15:16:20.586 INFO: Load New Code definition
15:16:20.611 DEBUG: GET 200 https://sonarqube.org.com/api/new_code_periods/show.protobuf?project=ansible-model-repo&branch=uat | time=22ms
15:16:20.615 INFO: Load New Code definition (done) | time=28ms
15:16:20.619 INFO: Analysis report generated in 139ms, dir size=234.6 kB
15:16:20.629 INFO: Analysis report compressed in 10ms, zip size=30.5 kB
15:16:20.631 INFO: Analysis report generated in /home/jenkins/agent/workspace/vices_UAT_ansible-model-repo_uat/.scannerwork/scanner-report
15:16:20.631 DEBUG: Upload report
15:16:20.674 DEBUG: POST 200 https://sonarqube.org.com/api/ce/submit?projectKey=ansible-model-repo&characteristic=branch%3Duat&characteristic=branchType%3DBRANCH | time=42ms
15:16:20.679 INFO: Analysis report uploaded in 48ms
15:16:20.682 DEBUG: Report metadata written to /home/jenkins/agent/workspace/vices_UAT_ansible-model-repo_uat/.scannerwork/report-task.txt
15:16:20.682 INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarqube.org.com/dashboard?id=ansible-model-repo&branch=uat
15:16:20.682 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report

On the sonarqube side it shows:
The “uat” branch has no lines of code.

Please, let me know what might me the issue as CPD executor calculating showing 0 files.

Thanks,
Prabhjot

Hi Prabhjot,

Welcome to the community!

First, you’ve just published an analysis token to the internet. I hope you’ve already revoked it. :slight_smile:

Second, you’ve used withCredentials in your pipeline, which is intended to pull the SonarQube URL and credentials from global configuration, and then overridden the URL and credentials in your analysis command line. You should choose one or the other.

Regarding your actual question, you’ve given a snippet of your analysis log. Could you provide the full log, starting from at least the analysis command, redacted as necessary?

 
Thx,
Ann