you have to check the current folder path and check the file path of sonar-scanner.sh run using Jenkins pipeline is the same.
just check
jenkins pipeline changes:
stage-1-line:
pwd
echo "sonar start"
stage2-line:
pwd
sh sonar-scanner.sh
##here, "pwd" is the same when running the Jenkins pipeline and its path of the project folder.
If not then follow below step for sonar scanner:
###Running a Test Scan on SonarQube Example Projects
If you’d like to just poke around with SonarQube to see what it can do, you might consider running a test scan on the SonarQube example projects. These are example projects created by the SonarQube team that contains many issues that SonarQube will then detect and report.
##Create a new working directory in your home directory, then change to the directory:
cd ~
mkdir sonar-test && cd sonar-test
Download the example project:
wget https://github.com/SonarSource/sonar-scanning-examples/archive/master.zip
Unzip the project and delete the archive file:
unzip master.zip
rm master.zip
##Next, switch to the example project directory:
cd sonar-scanning-project-directory-path/myproject
###Run the scanner, passing it the token you created earlier:
sonar-scanner -D sonar.login=your_token_here
###Output:
This will take a while. Once the scan is complete, you’ll see something like this on the console:
INFO: Task total time: 14.128 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 21.776s
INFO: Final Memory: 17M/130M
INFO: ------------------------------------------------------------------------