2017-01-06 1 views
1

스캔 구성,하지만 누군가가 내가 잘못 뭐하는 거지에 직접 수 있다면 여기에없는 뭔가가있다 방법 : 아래 SonarQube에 대한 젠킨스 파이프 라인 내 프로젝트에 대한 젠킨스 파이프 라인을 구성하려고

파이프 라인이다 스크립트

다음
node { 
    stage('SonarQube analysis') { 
    // requires SonarQube Scanner 2.8+ 
    def scannerHome = tool 'sonarScanner'; 
    withSonarQubeEnv('SonarQube 6.2') { 
     bat "${scannerHome}/bin/sonar-runner.bat" 
    } 
    } 
} 

는 젠킨스 소나 플러그인 관련 구성입니다 : Manage Jenkins > Configure System에서 : enter image description here

01,238,001,723,643,754,972,462,253,321을 아래에서

D:\jenkins\workspace\Test_Pipeline>D:\sonar-runner-2.4/bin/sonar-runner.bat 
D:\sonar-runner-2.4 
SonarQube Runner 2.4 
Java 1.8.0_92 Oracle Corporation (64-bit) 
Windows Server 2008 R2 6.1 amd64 
INFO: Runner configuration file: D:\sonar-runner-2.4\conf\sonar-runner.properties 
INFO: Project configuration file: NONE 
INFO: Default locale: "en_US", source code encoding: "UTF-8" 
INFO: Work directory: D:\jenkins\workspace\Test_Pipeline\.\.sonar 
INFO: SonarQube Server 6.2 
19:48:53.627 INFO - Load global repositories 
19:48:53.920 INFO - Load global repositories (done) | time=298ms 
19:48:53.951 WARN - Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database. 
19:48:53.951 WARN - Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database. 
19:48:53.951 WARN - Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database. 
19:48:53.951 INFO - User cache: C:\Users\Administrator\.sonar\cache 
19:48:54.378 INFO - Load plugins index 
19:48:54.378 INFO - Load plugins index (done) | time=0ms 
19:48:55.235 INFO - Process project properties 
INFO: ------------------------------------------------------------------------ 
INFO: EXECUTION FAILURE 
INFO: ------------------------------------------------------------------------ 
Total time: 3.404s 
Final Memory: 5M/120M 
INFO: ------------------------------------------------------------------------ 
ERROR: Error during Sonar runner execution 
ERROR: Unable to execute Sonar 
ERROR: Caused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources 
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch. 
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging. 
[Pipeline] } 
[Pipeline] // wrap 
[Pipeline] } 
[Pipeline] // stage 
[Pipeline] } 
[Pipeline] // node 
[Pipeline] End of Pipeline 
ERROR: script returned exit code 1 
Finished: FAILURE 

문제는 내 sonar-project.properties가 배치된다 젠킨스는 모르는 것 같다 : 아래 enter image description here

0 내가 오류입니다. \ myprj 아래와 같이 내용이 있습니다 : 그것은 D 아래

# required metadata 
sonar.projectKey=my_prj:my_prj 
sonar.projectName=my_prj 
sonar.projectVersion=1.00 
sonar.sources=my_prj/src 
sonar.language=java 

Pls는 내가 sonar-project.properties 파일이

답변

4

좋아 배치되는 위치 젠킨스 파이프 라인이 인식 할 수있는 방법을 제안, 내가 생각 추측 무엇이 잘못되었는지. 스크립트에 작업 공간을 추가해야하고 다음과 같이 작동해야합니다.

stage('SonarQube analysis') { 
    ws('D:\\my_prj') { 
    // requires SonarQube Scanner 2.8+ 
    def scannerHome = tool 'sonarScanner'; 
    withSonarQubeEnv('SonarQube 6.2') { 
     bat "${scannerHome}/bin/sonar-runner.bat" 
    } 
    } 
} 
+0

이 게시물은 오래되었지만 내 프로젝트 루트 (내 gitlab을 사용하고 있습니다)에서 내 sonar-project.properties 파일을 설정하는 방법을 알려줄 수 있습니까? –

0

나는 Sonar-runner 2.4를 사용하는 것을 본 적이 있습니다. 2.8 버전을 실행하면 더 나은 결과를 얻을 수 있다고 생각합니다. 이것은 Declarative Pipeline 구문을 사용하여 JenkinsFile 구성입니다. 나는 똑같은 문제를 안고 있었지만 sonar-project.properties 파일의 이름을 바꾸어서 해결했다. 이전 이름은 "sonar.properties"였고 연구 (Sonarqube 공식 문서는 도움이되지 않았다. 나는 이것이 다른 사람들을 도울 수 있기를 바랍니다.

관련 문제