Maven Plugin fails with exception when trying to run on SonarCloud

Our internal customer is running is a Gitlab Server Pipeline (Maven build) connecting to sonarcloud and experiences the following error:

The following error occurs:
Caused by: org.sonar.api.utils.MessageException: Failed to get CE Task status - No activity found for task 'abcdexyz'

Pipeline output:
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project xxx: Failed to get CE Task status - No activity found for task 'abcdexyz'

Is this known behaviour? Retries seem to remedy it for the customer.
What can be done to prevent this error?

Edit: this also happens for gradle pipelines

Thanks!

Hey @voelda

  • What does their .gitlab-ci.yml file look like?
  • Can you confirm they are actually using Gitlab Server, as opposed to Gitlab.com?

Hi Colin,

I can confirm they are on Gitlab Server. This is a setup that is intentional, even though we know that most teams use sonarcloud and Gitlab.com.

This is the relevant part from their .gitlab-ci.yml:

.sonarcloud:
  <<: *tags
  image: registry.gitlab-server/sam/docker/maven-jdk15-node:latest
  script:
    - mvn $MAVEN_CLI_OPTS sonar:sonar -P sonar -Dsonar.gitlab.project_id=$CI_PROJECT_PATH -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME $ADDITIONAL_PARAMS
  variables:
    GIT_DEPTH: 0
  cache:
    policy: pull
    paths:
      - .m2/repository
  except:
    - schedules

Hey @voelda

Thanks for confirming. It’s a shame that your users won’t benefit from features like Merge Request Decoration. :frowning:

In any case, the error is strange. The next time this happens, try querying https://sonarcloud.io/api/qualitygates/project_status?analysisId=abcdexyz (using whatever ID is returned in the logs for the analysisId) and see if it returns any information. This is the same URL the scanner is calling. Let us know what happens.

It will be interesting to know if the analysis is actually making its way to SonarCloud and starting to be processed.

Hi Colin,

Thank you for the info. I’m getting the same problem for the last two days.

Failed to get CE Task status - No activity found for task ‘AX-Cvmk1Lj_oMlsUjiI_’ → [Help 1]

When I visit this address “https://sonarcloud.io/api/qualitygates/project_status?analysisId=AX-Cvmk1Lj_oMlsUjiI_
it says

{“errors”:[{“msg”:“Analysis with id \u0027AX-Cvmk1Lj_oMlsUjiI_\u0027 is not found”}]}

FYI

That’s interesting. It means we probably aren’t running into some race condition where the analysis report hasn’t started to be processed by SonarCloud…

Is this UUID the same as the one that’s reported at the end of the mvn sonar:sonar step?

[ **INFO** ] ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=testmaven
[ **INFO** ] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[ **INFO** ] More about the report processing at https://sonarcloud.io/api/ce/task?id=AX-HpkG_H2h4zpgubz7O

We recently started having the same issue. Sometimes it works and sometimes we get the No activity found for task error. This is now happening for a month if I am correct.

We are running into the same issue. Failed to get CE Task status - No activity found for task .... We figured out that ce-task which cannot be found is returning the needed information, when calling it manually: https://sonarcloud.io/api/ce/task?id=<ID-WHICH-CANNOT-BE-FOUND>
So we are guessing that the call is made before the information is provided sometimes.
We tried downgrading back to the previous version 3.9.0.2155 but without success.

Hey @paulhobbel / @Laksuh

Do you mind confirming what CI you’re using here (the original post was with GitLab CI) and DevOps Platform (the original post relates to GitLab Server). Understanding if there’s a pattern (or not) is really useful here.

Ofcourse, we are using GitLab CI as well on a self hosted GitLab Server.

We have same error in our Gitlab CI .

2 Likes

Looks like we have the similar issue: Quality Gate fails with ‘GET 404 https://sonarcloud.io/api/ce/task?id=AX-yXUIpYZn01BNPA1FR’ - Report a bug - Sonar Community (sonarsource.com)

Hi @Colin,

is there something we can do to get more attention on this issue?
We will gladly provide more information if needed/available.

  • SonarCloud, SonarScanner for MSBuild 5.5.3
16:02:10.694 DEBUG: Report metadata written to /builds/dev-uk/micro-space/application-container/.sonarqube/out/.sonar/report-task.txt
16:02:10.694 INFO: ------------- Check Quality Gate status
16:02:10.694 INFO: Waiting for the analysis report to be processed (max 300s)
16:02:10.705 DEBUG: GET 404 https://sonarcloud.io/api/ce/task?id=AX-yXUIpYZn01BNPA1FR | time=11ms
16:02:10.710 DEBUG: eslint-bridge server will shutdown
16:02:16.090 INFO: ------------------------------------------------------------------------
16:02:16.090 INFO: EXECUTION FAILURE
16:02:16.090 INFO: ------------------------------------------------------------------------
16:02:16.090 INFO: Total time: 1:10.743s
16:02:16.149 INFO: Final Memory: 38M/137M
16:02:16.149 INFO: ------------------------------------------------------------------------
16:02:16.149 ERROR: Error during SonarScanner execution
Failed to get CE Task status - No activity found for task 'AX-yXUIpYZn01BNPA1FR'
Process returned exit code 2
The SonarScanner did not complete successfully

Appears randomly, sometimes helps restarts, sometimes restart works from 2,3,4 try.
This is how we run it:

 dotnet sonarscanner begin /o:XXX /k:$SONAR_CLOUD_PROJECT /d:sonar.host.url=https://sonarcloud.io /d:sonar.login=$SONAR_TOKEN /d:sonar.qualitygate.wait=true /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml  /d:sonar.javascript.lcov.reportPaths=**/lcov.info /d:sonar.exclusions=$SONAR_EXCLUSIONS /d:sonar.cpd.exclusions=$SONAR_EXCLUSIONS_DUPLICATION /d:sonar.coverage.exclusions=$SONAR_EXCLUSIONS_COVERAGE /v:$VERSION
    dotnet build
    dotnet sonarscanner end /d:sonar.login=$SONAR_TOKEN

Analysis run in container, so no leftovers should be anywhere.

FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine
ENV PATH "$PATH:/root/.dotnet/tools"
RUN apk update && apk add openjdk11 nodejs npm bash git openssh
RUN wget https://dot.net/v1/dotnet-install.sh
RUN chmod +x dotnet-install.sh
RUN ./dotnet-install.sh -c 5.0 --install-dir /usr/share/dotnet
RUN dotnet tool install --global dotnet-sonarscanner

Hey all. This thread has been flagged for attention by our internal development team.

We are also using GitLab CI, not sure if it’s a pattern

Hi @Colin

Could you give a suggestion for a workaround?

Hello @Matti_van_Aert ,

not Colin, but my team currently uses retry: 1 for our sonarcloud step in our pipeline. Very unpleasant as pipelines take a little longer, but a lot less manual overhead for retrying such failed steps. At least for now automatically created pipelines (e.g. by renovate) tend to fail less often.

Hope this helps. A non-flaky fix / workaround would be preferable though.

Hi @Colin,
Is there a ticket or issue id to indicate if it is being worked on or not?

2 Likes

I’m having the same issue with a sonar-scanner call.
Our gitlab job looks like this

sonarcloud-check:
  stage: sonar
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  script:
    - sonar-scanner

And from time to time, it fails with

INFO: Analysis report generated in 193ms, dir size=310 KB
INFO: Analysis report compressed in 177ms, zip size=179 KB
INFO: Analysis report uploaded in 195ms
INFO: ------------- Check Quality Gate status
INFO: Waiting for the analysis report to be processed (max 300s)
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 31.787s
INFO: Final Memory: 60M/143M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Failed to get CE Task status - No activity found for task 'XXXXXXXXXX'