Search code examples
azure-devopssonarqube

SonarQube Publish Quality Gate Result error 400: API GET '/api/ce/task' failed, status code was: 400


After producing build warnings as expected, I'm finding that My SonarQube Publish Quality Gate Result step gets to an error 400 and I appear to have hit a bit of a dead end in getting it set up.

Logs show:

##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXsb0WQ3LC6AkZHS05UY","additionalFields":"warnings"}"
##[debug]Response: 200 Body: "{"task":{"id":"AXsb0WQ3LC6AkZHS05UY","type":"REPORT","componentId":"AXsbe3pELC6AkZHS05UN","componentKey":"my-project-key","componentName":"my-component-namel","componentQualifier":"TRK","status":"IN_PROGRESS","submittedAt":"2021-08-06T15:15:12+0100","submitterLogin":"admin","startedAt":"2021-08-06T15:15:13+0100","executionTimeMs":24228,"logs":false,"organization":"default-organization"}}"
##[debug][SQ] Task status:IN_PROGRESS
##[debug][SQ] Waiting for task 'AXsb0WQ3LC6AkZHS05UY' to complete.
##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXsb0WQ3LC6AkZHS05UY","additionalFields":"warnings"}"
##[debug]Response: 200 Body: "{"task":{"id":"AXsb0WQ3LC6AkZHS05UY","type":"REPORT","componentId":"AXsbe3pELC6AkZHS05UN","componentKey":"my-project-key","componentName":"my-component-namel","componentQualifier":"TRK","status":"IN_PROGRESS","submittedAt":"2021-08-06T15:15:12+0100","submitterLogin":"admin","startedAt":"2021-08-06T15:15:13+0100","executionTimeMs":25343,"logs":false,"organization":"default-organization"}}"
##[debug][SQ] Task status:IN_PROGRESS
##[debug][SQ] Waiting for task 'AXsb0WQ3LC6AkZHS05UY' to complete.
##[debug][SQ] API GET: '/api/ce/task' with query "{"id":"AXsb0WQ3LC6AkZHS05UY","additionalFields":"warnings"}"
##[debug]Response: 400 Body: "{"errors":[{"msg":"Value of parameter 'additionalFields' (warnings) must be one of: [stacktrace, scannerContext]"}]}"
##[debug][SQ] API GET '/api/ce/task' failed, status code was: 400
##[error][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug][SQ] Publish task error: [SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]task result: Failed
##[error][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]Processed: ##vso[task.issue type=error;][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]Processed: ##vso[task.complete result=Failed;][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
Finishing: SonarQubePublish

Oddly, the logs show the same API GET: '/api/ce/task' requests running with the same arguments and receiving a 200 response before getting to:

##[debug][SQ] API GET '/api/ce/task' failed, status code was: 400
##[error][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/ce/task' failed, status code was: 400
##[debug][SQ] Publish task error: [SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'
##[debug]task result: Failed
##[error][SQ] Could not fetch task for ID 'AXsb0WQ3LC6AkZHS05UY'

I've found examples of 404 and 401 errors for this same GET request but no mentions of a 400 response.

Azure DevOps configuration looks like:

- task: SonarQubePrepare@4
  inputs:
    SonarQube: 'SonarQube Connection'
    scannerMode: 'MSBuild'
    projectKey: 'my-project-key'
    projectName: 'my-project-name'
    extraProperties: |
      # Additional properties that will be passed to the scanner, 
      # Put one key=value per line, example:
      # sonar.exclusions=**/*.bin
      sonar.verbose=true

# Build the entire solution so the test assemblies are available
- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    solution: MySolution.sln
    platform: 'Any CPU'
    configuration: 'Release'

- task: SonarQubeAnalyze@4
- task: SonarQubePublish@4
  inputs:
    pollingTimeoutSec: '300'

I'm running Devops from the cloud (if that matters) and SonarQube v 6.7. What am I doing wrong?


Solution

  • The solution as provided at https://community.sonarsource.com/t/sonarqube-publish-quality-gate-result-error-400-api-get-api-ce-task-failed-status-code-was-400/47735 is to upgrade to a more modern version. 6.7 is ancient.