Azure devOps and SonarSource SonarQube plugin

I am running Azure DevOps CI/CD pipelines and just added SonarQube to one of them.
At the end we are running a SonarQube community version v. 8.9.7.

I get this error: “To use the property “sonar.branch.name” and analyze branches, Developer Edition or above is required”. The error is clear, but I have not added a branch name anywhere.

The pipeline yaml looks like this:

> trigger:
>   branches:
>     include:
>     - develop
>   batch: True
> name: $(date:yyyyMMdd)$(rev:.r)
> resources:
>   repositories:
>   - repository: self
>     type: git
>     ref: refs/heads/develop
> jobs:
> - job: Phase_1
>   displayName: Phase 1
>   cancelTimeoutInMinutes: 1
>   pool:
>     name: Default
>   steps:
>   - checkout: self
>   - task: NodeTool@0
>     displayName: Use Node 14.x
>     inputs:
>       versionSpec: 14.x
>       checkLatest: true
>   - task: DotNetCoreInstaller@0
>     displayName: Use .NET Core sdk 6.0.101
>     inputs:
>       version: 6.0.101
>   - task: SonarQubePrepare@5
>     displayName: Prepare analysis on SonarQube
>     inputs:
>       SonarQube: XXX
>       projectKey: XXX
>       projectName: XXX
>   - task: VisualStudioTestPlatformInstaller@1
>     displayName: VsTest Platform Installer
>     inputs:
>       versionSelector: specificVersion
>       testPlatformVersion: 16.8.3
>   - task: NuGetToolInstaller@0
>     displayName: Use NuGet 5.8.x
>     inputs:
>       versionSpec: 5.8.x
>   - task: DotNetCoreCLI@2
>     displayName: dotnet custom
>     inputs:
>       command: custom
>       projects: '**/XXX.sln'
>       custom: restore
>       arguments: --source https://XXX -r win-x86
>       selectOrConfig: config
>   - task: DotNetCoreCLI@2
>     displayName: dotnet build
>     inputs:
>       projects: '**/XXX.sln'
>       arguments: /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="bin\WebAppContent" /p:BuildPlatform="$(BuildPlatform)" /p:BuildConfiguration="$(BuildConfiguration)"
>   - task: MSBuild@1
>     displayName: Build solution **/XXX.sln
>     enabled: False
>     inputs:
>       solution: '**/XXX.sln'
>       msbuildLocationMethod: location
>       msbuildLocation: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe
>       platform: $(BuildPlatform)
>       configuration: $(BuildConfiguration)
>       msbuildArguments: /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="bin\WebAppContent" /p:RuntimeIdentifier=win-x86
>       maximumCpuCount: true
>       logProjectEvents: true
>   - task: VSTest@2
>     name: VSTest_4
>     displayName: Test Assemblies **\$(BuildConfiguration)\*test*.dll;-:**\obj\**
>     inputs:
>       testAssemblyVer2: >-
>         **\*unittest*.dll
> 
>         !**\obj\**
> 
>         !**\ref\**
>       runOnlyImpactedTests: false
>       vsTestVersion: toolsInstaller
>       runInParallel: true
>       codeCoverageEnabled: true
>       platform: $(BuildPlatform)
>       configuration: $(BuildConfiguration)
>   - task: SonarQubeAnalyze@5
>     displayName: Run Code Analysis
>   - task: SonarQubePublish@5
>     displayName: Publish Quality Gate Result
>   - task: ArchiveFiles@2
>     displayName: Archive Apps.Api
>     inputs:
>       rootFolderOrFile: source\Apps\Apps.Api\bin\WebAppContent
>       includeRootFolder: false
>       archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).Apps.Api.zip
>   - task: ArchiveFiles@2
>     displayName: Archive Hub.Api
>     inputs:
>       rootFolderOrFile: source\Hub\Hub.Api\bin\WebAppContent
>       includeRootFolder: false
>       archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).Hub.Api.zip
>   - task: ArchiveFiles@2
>     displayName: Archive Rmi.Api
>     inputs:
>       rootFolderOrFile: source\Rmi\Rmi.Api\bin\WebAppContent
>       includeRootFolder: false
>       archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).Rmi.Api.zip
>   - task: ArchiveFiles@2
>     displayName: Archive Hub.WebClient
>     inputs:
>       rootFolderOrFile: source\Hub\Hub.WebClient\bin\WebAppContent
>       includeRootFolder: false
>       archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).Hub.WebClient.zip
>   - task: CopyFiles@2
>     name: CopyFiles_5
>     displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
>     enabled: False
>     inputs:
>       SourceFolder: $(build.sourcesdirectory)
>       Contents: '**\bin\$(BuildConfiguration)\PublishOutput\**'
>       TargetFolder: $(build.artifactstagingdirectory)
>       CleanTargetFolder: true
>   - task: PublishBuildArtifacts@1
>     name: PublishBuildArtifacts_6
>     displayName: 'Publish Artifact: drop'
>     inputs:
>       PathtoPublish: $(build.artifactstagingdirectory)
>       TargetPath: '\\my\share\$(Build.DefinitionName)\$(Build.BuildNumber)'

You trigger the pipeline not from master but from develop branch.
If you dont set the branch name it will take from what the current context is, which is the develop branch or the ref pointer in the repository section

Hi ArieHein

Thx for your answer.

So… what you are telling me is that I will not be able to use SonarQube Community version with the Azure SonarQube plugin on anything but my production branch, even when the development branch is tagged as the major branch (located in AWS CodeCommit) ? Our production branch is not even called “master” but “main”.

FYI:
I have a local SonarQube Community version installed for POC and that one runs fine on the same repo and branch.

A colleague of mine sent me this link https://community.sonarsource.com/t/error-to-use-the-property-sonar-branch-name-and-analyze-branches/11962/6 which actually “solves” the problem.

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