简体   繁体   中英

Sonar scanner running on local but does not work with jenkins pipeline

I want run command on ser sonar-scanner or sonar-scanner -Dsonar.projectKey=node-myapp -Dsonar.sources=. -Dsonar.host.url=http://ip:9000 -Dsonar.login=key

I am trying with run .sh file in pipeline or direct scan from pipeline working on file but not work form jenkins pipeline and got error:

Error:sonar-scanner.sh: 4: sonar-scanner: not found

also ERROR: script returned exit code 127 在此处输入图片说明

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: ------------------------------------------------------------------------

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM