我正在NodeJS中運行一個小項目。我正在使用TravisCI來幫助持續集成。作爲持續集成的一部分,我想與sonarqube集成來分析代碼。TravisCI與SonarQube集成導致不支持major.minor版本52.0
這是travis.yml
language: node_js
node_js:
- "6"
addons:
sonarqube: true
env:
SONAR_TOKEN: b9a731b8b00b0cff2299cc21b103855570522cea
script:
# other script steps might be done before running the actual SonarQube analysis
- sonar-scanner -Dsonar.login=b9a731b8b00b0cff2299cc21b103855570522cea
這是sonarqube屬性文件:
# must be unique in a given SonarQube instance
sonar.projectKey=sheidaei:coffeeclub
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=Coffee Club
sonar.projectVersion=0.0.1
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
您可以在github項目@https://github.com/sheidaei/coffeeclub
後自動整個源建立在TravisCI,我總是與sonarqube出現錯誤。它告訴我,它與major.minor版本有關。我不知道如何解決這個問題,以及如何強制爲travisci或sonarqube版本的java。任何想法/幫助表示讚賞。
Preparing SonarQube Scanner CLI
Archive: /home/travis/.sonarscanner/sonar-scanner.zip
creating: /home/travis/.sonarscanner/sonar-scanner-2.8/
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/bin/sonar-scanner.bat
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/bin/sonar-scanner-debug
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/lib/sonar-scanner-cli-2.8.jar
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/bin/sonar-scanner
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/conf/sonar-scanner.properties
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/bin/sonar-runner.bat
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/bin/sonar-runner
inflating: /home/travis/.sonarscanner/sonar-scanner-2.8/bin/sonar-scanner-debug.bat
$ export SONAR_SCANNER_HOME=$HOME/.sonarscanner/sonar-scanner-2.8
sonarqube.run
Preparing SonarQube Scanner parameters
0.22s$ sonar-scanner -Dsonar.login=b9a731b8b00b0cff2299cc21b103855570522cea
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/cli/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
The command "sonar-scanner -Dsonar.login=b9a731b8b00b0cff2299cc21b103855570522cea" exited with 1.
Done. Your build exited with 1.
您必須使用Java 8。升級。 – BadZen