Wie die Konfiguration eines Jenkins-Pipeline für SonarQube scan
Ich versuche zu konfigurieren, dass ein jenkins-pipeline für mein Projekt, aber es fehlt etwas hier, wenn jemand könnte direkt auf das, was ich falsch mache:
Unten ist die pipeline-Skript:
node {
stage('SonarQube analysis') {
//requires SonarQube Scanner 2.8+
def scannerHome = tool 'sonarScanner';
withSonarQubeEnv('SonarQube 6.2') {
bat "${scannerHome}/bin/sonar-runner.bat"
}
}
}
Unten ist die Jenkins-Sonar-Plugin-bezogene Konfigurationen:
Unter Manage Jenkins > Configure System
:
Unter Manage Jenkins > Global Tool Configuration
Unten ist die Fehlermeldung, die ich bekomme:
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
Das problem scheint, dass Jenkins nicht weiß, wo meine sonar-Projekt.Eigenschaften gelegt wird. Es ist unter D:\myprj und hat den Inhalt wie folgt:
# 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 vorschlagen, wie ich das machen kann Jenkins-pipeline bewusst ist, wo die sonar-Projekt.Eigenschaften-Datei platziert wird
InformationsquelleAutor user5917011 | 2017-01-06
Du musst angemeldet sein, um einen Kommentar abzugeben.
Brauchte ich zum hinzufügen von workspace zu meinem Skript. Hier ist das Skript:
Ich würde gerne mit dem eingebauten Sonar-scanner, der automatisch installiert wird . In diesem Fall gibt es keine Notwendigkeit zu passieren, eine sh-oder bat-Befehl angeben, der Pfad von sonar-runner richtig ?
InformationsquelleAutor user5917011
Ich sehe, Sie wurden mit Hilfe von Sonar-runner 2.4. Ich denke, durch ausführen von 2.8-version haben Sie bessere Ergebnisse. Dies ist mein JenkinsFile-Konfiguration, die durch Deklarative Pipeline syntax. Ich hatte das gleiche Problem, aber ich gelöst mit dem umbenennen meine sonar-Projekt.properties-Datei, die der Vorherige name war "sonar.Eigenschaften" und recherchieren(Die Sonarqube offiziellen docs hat mir nicht helfen). Ich hoffe, dass dies anderen helfen kann.
InformationsquelleAutor Vivi Ch