Sonar Qube 8.9 LTS developer edition with Azure Dev Ops self hosted pipeline agent is not scanning

  • SonarQube 8.9 LTS Developer edition, maven 3.6.3
  • want to analyze repository brances - auto detection branches done but not getting analysed
  • As per sonar docs and sonar qube dev edition configuration project steps followed exactly.
    Service connection created and token from sonar qube generated and project configured.
    Its java project. Below pipeline tasks configured.
    1. Prepare analaysis task (from sonar qube Azure dev ops extension from marketplace)
    2. Maven build by selecting the check box of Run Sonar qube or sinar cloud analysis from advanced code anlysis option
    3. Publish code analysis results

All 3 are configured as 3 stages each having a job for above by pointing self hosted agent. Execution is successful. But source code is not getting analyzed. However if we configure same tasks under 1 single job as 3 different steps its failing with error as “No agent found in pool SonarQubeCodeAnalyser-Agent which satisfies the specified demands: agent.name -equals SonarQubeCodeAnalyserVM, maven, Agent.Version -gtVersion 2.163.1”

Below is the Yaml.

trigger:

  • master
    stages:
  • stage: A
    jobs:
    • job: Analyser
      pool:
      name: SonarQubeCodeAnalyser-Agent
      demands:
      - agent.name -equals SonarQubeCodeAnalyserVM

      steps:

      • task: CmdLine@2
        inputs:
        script: ‘echo Hello world’

      • task: SonarQubePrepare@5
        inputs:
        SonarQube: ‘SonarQubeDevEditionForGenNXT’
        scannerMode: ‘Other’
        extraProperties: ‘sonar.projectKey=GenNXT_GenNXT’

  • stage: B
    jobs:
    • job: Build
      pool:
      name: SonarQubeCodeAnalyser-Agent
      demands:

      • agent.name -equals SonarQubeCodeAnalyserVM

      steps:

      • task: Maven@3
        inputs:
        mavenPomFile: ‘D:/Selfhostedagents/_work/2/s/ParentProject/pom.xml’
        publishJUnitResults: true
        testResultsFiles: ‘**/surefire-reports/TEST-*.xml’
        javaHomeOption: ‘JDKVersion’
        jdkVersionOption: ‘1.8’
        mavenVersionOption: ‘Path’
        mavenDirectory: ‘C:\Maven\apache-maven-3.6.3\bin’
        mavenSetM2Home: false
        mavenAuthenticateFeed: false
        effectivePomSkip: false
        sonarQubeRunAnalysis: true
        sqMavenPluginVersionChoice: ‘pom’
        goals: ‘package’
  • stage: C
    jobs:
    • job: Publishser

      pool:
      name: SonarQubeCodeAnalyser-Agent
      demands:

      • agent.name -equals SonarQubeCodeAnalyserVM

      steps:

      • task: SonarQubePublish@5
        inputs:
        pollingTimeoutSec: ‘600’

Hey there.

So what does happen, or how do you know the code wasn’t analyzed?

Thanks for your reply, got it resolved now. Its not showin passed or failed in sinar qube, rather it says project yet to be analysed.

Did 2 changes, It has to be 1 single job with sequencing steps (because every job will do post job clean up), so output of previous step can be used. secondly, maven build refers environment variables and installed required software in self hosted agent machine. Earlier the idea was to use self hosted agent only for sonar qube analysis preparation.