Pull-request-analysis

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • what have you tried so far to achieve this

SonarQube: 9.9.0.65466
Bitbucket Branch SourceVersion 820.v30b_e8c1e36f3
SonarScanner for MSBuild 5.13

While testing and reviewing logs in an attempt to speed up this process, I noticed the following:

12:27:41.153 Incremental PR analysis: Base branch parameter was not provided.
12:27:41.153 Cache data is empty. A full analysis will be performed.

Then I reviewed this page:

If I run the process by manually adding the sonar.pullrequest parameters, the pull request analysis seems to work as expected. However, I don’t know how to get this to work automatically. As usual, documentation is very lacking.

Any ideas on what I might do to get this setup to work automatically with BitBucket?

Thanks,

Tony

Hi Tony,

Since those values should be filled in from the environment, I suspect this is about your checkout, and the underlying data available on your project/PR in the environment.

Can you share what/how you check your project out for analysis?

Also, to make sure, you are using Bitbucket Pipelines, right?

 
Thx,
Ann

Hi Ann,

Actually, we just switched over to BitBucket Cloud this week, so I need to redo the setup. If things continue to not work as desired, I will post my setup.

Thank you,

Tony

1 Like

Hi Ann,

Yes, we are using BitBucket Pipelines.

The plugin is:

Bitbucket Push and Pull Request Plugin

I am not sure I totally understand what you are asking, but will provide what I can:

        stage('SonarQube Analysis') {
            environment {
              msbuildHome = tool 'MSBuild 17.3.0'
              scannerHome = tool 'SonarScanner for MSBuild for RosterApps'
            }
        
            steps {
              withSonarQubeEnv('Arcos-Sonarqube') {
                bat "\"${scannerHome}\\SonarScanner.MSBuild.exe\" begin /k:\"SOME_VALUE\""
                powershell('''
                        Write-Host "Starting RosterApps.Web Build"
                        $env:PATH = "$env:PATH;C:\\Program Files\\nodejs;C:\\Users\\sa_jenkins\\AppData\\Roaming\\npm"
                        "appSettings.config", "connectionStrings.config", "qciFramework.config" | ForEach-Object {
                            Copy-Item $env:WORKSPACE\\RosterApps.Web\\ConfigTemplates\\$_ $env:WORKSPACE\\RosterApps.Web\\Config -Recurse -Force
                        }
                    ''')
                bat "\"${msbuildHome}\\MSBuild.exe\" RosterApps.sln /t:Rebuild /p:CurrentDirectory=%~dp0\\ -v:quiet"             
                powershell('''
                        Write-Host "Starting RosterApps.Web Angular Build"
                        # Angular Build
                        cd $env:WORKSPACE\\RosterApps.Web
                        ng build EnhancedVacationBidding --output-path="..\\RosterApps.Web.Deploy\\Publish Debug\\EnhancedVacationBidding" --configuration production
                        ng build TimeAndAttendance --output-path="..\\RosterApps.Web.Deploy\\Publish Debug\\TimeAndAttendance" --configuration production
                    ''')
                    
                bat "\"${scannerHome}\\SonarScanner.MSBuild.exe\" end"                
              }            
            }
        }   
    

Is the above what you need?

Thanks,

Tony

Hi Tony,

Let’s go back to your OP:

This is purely informational & probably disappeared on subsequent analyses, right?

This is the part that’s about your checkout. Those things are read from the environment, so what this message tells us is that the PR’s target branch couldn’t be read from the environment.

What you’ve provided about your pipeline doesn’t include the checkout. But the docs may help you sort it out.

 
Ann