ERROR: Unable to parse file [/path] at line xx

Hi, my friends!

Someone can I help me?

I have a stage on the Jenkins pipelie that parse the code with sonarscanner and this stage is returning “quality gate” error [UNSTABLE], your version is [ sonar: scannerHome = tool ‘SonarScanner3.2.0.1227’].

The error is “ERROR: Unable to parse file [path of the code] at line 27”.

The developers says that the code is correct, but the sonarqube tests return this error.

It seems this version the sonarscanner doesn’t support PHP 8.1 syntax, and the devops team can’t upgrade the plugin. How I can correct this?

This code check the quality gate

        qg = waitForQualityGate()
        echo qg.toString()
        qualityGateStatus = qg.status.toString()
        if (qg.status != 'OK') {
              currentBuild.result = 'UNSTABLE'
              addDescription('ALERTA!: Verifique issues no Sonar!')

In attached some printscreen.


image-20230523-182636

Hey there.

What version of SonarQube are you using? This can be found in the footer of your SonarQube instance.

Thank you for answer!

Versão do sonar: scannerHome = tool ‘SonarScanner3.2.0.1227’
ServerVersion=8.9.10.61524

Remembering, It running in the Jenkins pipeline.

  stage('Sonar') {
    steps {
      gitlabCommitStatus(name: '05 Sonar') {
        script {
          def scannerHome = tool 'SonarScanner3.2.0.1227';
          withSonarQubeEnv('SonarDefault') {

          sh "${scannerHome}/bin/sonar-scanner"
          sh "cat .scannerwork/report-task.txt"
          }
          timeout (time: 1, unit: 'MINUTES') {
            qg = waitForQualityGate()
            echo qg.toString()
            qualityGateStatus = qg.status.toString()
            if (qg.status != 'OK') {
                  currentBuild.result = 'UNSTABLE'
                  addDescription('ALERTA!: Verifique issues no Sonar!')
            }
          }
        }
      }
      echo "Step Sonar: ${currentBuild.currentResult}"
    }
  }

Thanks.

SonarQube v8.9 LTS does not support PHP 8.1. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

8.9.10 → 9.9 → 10.0 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

I know, but I’m working into the client environment and they won’t upgrade version this moment. What do I do for bypass?

You can exclude these files from analysis entirely

Good, thanks! I’LL try

Please, one more question!

we talk about the version server sonarqube, however the scanner that make verification (“SonarScanner3.2.0.1227”) and write the result in the sonarqube. If I upgrade only the scanner, it’s will working ?

No. You need to upgrade the SonarQube server.