waitForQualityGate in Jenkins pipeline

Hey,

I am adding SonarQube as part of Jenkins pipeline as shown below:

        stage('SonarQube') {
            steps {
                withSonarQubeEnv('sonarqube') {
                    sh "${scannerHome}/bin/sonar-scanner.bat"
                }
            }
        }
        stage("Quality Gate") {
            steps {
                timeout(time: 1, unit: 'HOURS') {
                waitForQualityGate abortPipeline: true
                }
            }   
        }

Firstly, I have configured the SonarQube server details under the Jenkins configuration.

Secondly, I also configured the SonarQube Scanner

Moreover, I have added a webhook at the SonarQube Server so that once the scanning of the project is completed, Jenkins will get the response and continue further based upon the status.

When I am trying to build the job, I am getting an error at the “Quality Gate stage” of the pipeline (refer above).

Jenkins is unable to locate “report-task.txt” in the workspace.
I tried using sonar.analysis.mode=publish, but it is deprecated. Is there any alternate solution to generate the report so that Jenkins is aware of the task id? How to solve this issue?

Jenkins version: 2.277.3
SonarQube verison: 8.2