You're not authorized to run analysis. No sonar.login or SONAR_TOKEN env variable was set

I’m trying to add my github project to sonarclound, i do all the require step like add new organization, add project and when in the step configure project i get stuck, i do the exactly every step but it still can’t not configure:
I add the SONAR_TOKEN:


i add the SONAR_TOKEN to build.yml file:

I added required sonar-project.properties

But it won’t work, so i use the cli, using this function to add the scanner:

export SONAR_SCANNER_VERSION=4.7.0.2747
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-macosx
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-macosx.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"

Use this to add to current project:

sonar-scanner \
  -Dsonar.organization=khanh21011999 \
  -Dsonar.projectKey=khanh21011999_testUnitTest \
  -Dsonar.sources=. \
  -Dsonar.host.url=https://sonarcloud.io

But it return this in the terminal


ERROR: You're not authorized to run analysis. No sonar.login or SONAR_TOKEN env variable was set

ERROR:

ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.```

Please help, what did i do wrong?

Hey there.

Checking your GitHub repository, it looks like your GitHub Actions build.yml file has been consistently malformed. I would recommend copying what’s in the SonarCloud UI tutorial exactly (except changing the branch name from master to main).

You run into this issue locally as you haven’t passed sonar.login or set the SONAR_LOGIN environment variable (export SONAR_TOKEN=)

Hi Colin, i will try again and report you, thank for your answer

Hi Colin, somehow it lead to this problem after i successful make it work as you said ( thank you again Colin) , please help :((