All projects failing on MR pipelines. Main branch analysis is treating all code as new code

Greetings,

Starting overnight, all of our pipelines running on Merge Requests in Gitlab are failing with

ERROR: Error during SonarScanner execution
ERROR: Project not found. Please check the 'sonar.projectKey' and 'sonar.organization' properties, the 'SONAR_TOKEN' environment variable, or contact the project administrator to check the permissions of the user the token belongs to

The same error happens on both maven and javascript jobs. I tried recreating the sonar token in one project and it didn’t help.

The same job is working on the main branch, but all code seems to be treated as new code?

This project was green yesterday, and it shows over 1k new issues on the main branch today with zero new code changes, just re-running the same pipeline against the same code.


Here’s our JS job definition:

sonarcloud-check:
  stage: test
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  dependencies:
    - test
  needs:
    - test
  variables:
    GIT_DEPTH: "0"
    GIT_STRATEGY: clone
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - sonar-scanner
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  tags:
    - light

and our maven job definition:

sonarcloud:
  stage: visualize
  extends: .maven:setup
  needs:
    - maven:compile
    - maven:test
  dependencies:
    - maven:compile
    - maven:test
  cache:
    policy: pull
  variables:
    GIT_DEPTH: "0"
    GIT_STRATEGY: clone
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
  script:
    - ./mvnw sonar:sonar -Dsonar.projectKey=triValence_$CI_PROJECT_NAME -Dmaven.repo.local=$MAVEN_USER_HOME -Dsonar.qualitygate.wait=true
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Please let me know what additional details you may need to assist with both of these issues. I’m afraid the only workaround I have for keeping our merge requests moving is to allow the sonar job to fail for now.

This was caused by an expired gitlab pat. I was thrown off by the fact that it wasn’t failing on main.

1 Like

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