Could not find the pullrequest with key

Hi,

I’m getting this error on Azure DevOps pipeline

##[error]ERROR: Error during SonarScanner execution
ERROR: Could not find the pullrequest with key ‘9’
ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=XXXXXXXX&pullrequestKey=9 : {“errors”:[{“msg”:“Requested resource wasn\u0027t found on Azure DevOps.”,“reason”:“AZURE_DEVOPS_UNABLE_TO_FETCH_REQUESTED_RESOURCE”}]}

The analysis is working on standard branches, but not on PR…

Any help ?

Hi @squemene,

Welcome to the community!

This error indicates that the pull request with key 9 is not yet created during the analysis. Do your pipeline run after the pull request is created in Azure DevOps? In other words, is the pull request with key 9 created when you run the azure devops pipeline with sonarcloud scanning?

Can you tell me also, how do you execute the scan? Could you share your pipeline configuration (stripped of private data)?

Best,
Marcin

Hi @Marcin_Majewski

Unfortunately, the pipeline is triggered by the PR
The pipeline is working on any other branch…

The pipeline looks like, in a dedicated Sonar job :

- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'sonarcloud'
    organization: 'my-org'
    scannerMode: 'CLI'
    configMode: 'file'
    extraProperties: |
      sonar.projectKey=my-org_my-project
      sonar.projectName=my-project

- task: Maven@3
  displayName: 'Maven verify'
  inputs:
    mavenPomFile: 'pom.xml'
    goals: 'org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report'
    options: '$(mvnCliOpts)'
    publishJUnitResults: true
    testResultsFiles: '**/*-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    mavenVersionOption: 'Path'
    mavenDirectory: '$(Build.SourcesDirectory)/maven/apache-maven-3.6.3'
    mavenSetM2Home: true
    mavenOptions: '-Xmx3072m'
    mavenAuthenticateFeed: true
    effectivePomSkip: false
    sonarQubeRunAnalysis: false
    checkStyleRunAnalysis: false
    pmdRunAnalysis: false
    findBugsRunAnalysis: false

- task: SonarCloudAnalyze@1
  displayName: 'Run Code Analysis'

- task: SonarCloudPublish@1
  displayName: 'Publish Quality Gate Result'

I finally managed to make the pipeline work (Sonar analysis via a PR) by recreating the project in SonarCloud …

1 Like

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