我的项目正在使用java 8和sonarqube插件
id 'org.sonarqube' version '2.6.2'
。当我使用命令 ./gradlew clean build
构建项目时,它构建得很好。
但是当我尝试运行
./gradlew sonarqube
时,出现错误
* What went wrong:
Execution failed for task ':sonarqube'.
> org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent
version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
我的声纳任务看起来像什么
sonarqube {
properties {
properties["sonar.analysis.mode"] = "publish"
properties["sonar.projectKey"] = System.getenv("SONAR_PROJECT_KEY").toString().trim()
properties["sonar.projectName"] = System.getenv("SONAR_PROJECT_NAME").toString().trim()
properties["sonar.host.url"] = System.getenv("SONAR_HOST").toString().trim()
properties["sonar.login"] = System.getenv("SONAR_TOKEN").toString().trim()
properties["sonar.branch.name"] = System.getenv("CI_COMMIT_REF_NAME").toString().trim()
switch(System.getenv("CI_COMMIT_REF_NAME").toString().trim()) {
case ~/^feature\/MDS-.*$/:
properties["sonar.branch.target"] = "develop"
break
case 'master':
case 'develop':
break
default:
properties["sonar.branch.target"] = "master"
break
}
properties["sonar.exclusions"] = "**/analytics/model/**/*.java"
properties["sonar.coverage.exclusions"] = "**/analytics/model/**/*.java"
}
}
我尝试了这个答案使用Java 11运行SonarScanner分析,使用Java 8运行目标代码
# build successful
./gradlew clean build
# change to java 11
$env:JAVA_HOME="C:\Users\wv3cxq\Downloads\jdk-11.0.12_windows-x64_bin\jdk-11.0.12"
# Tried to run sonarqube task
./gradlew sonarqube
然后出现以下错误
* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
我的公司使用 gitlab runner 和 openjdk 8,sonarqube 工作正常。我不知道怎么办?我还附加了 dockerfile。可能有人会理解为什么它在那里工作而不是在我的机器上工作。
我删除了一些敏感部分
FROM alpine:3.7
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/bin/
RUN apk --no-cache update && \
apk --no-cache add \
openjdk8=8.171.11-r0 \
docker=17.12.1-r0 \
&& \
pip --no-cache-dir install docker-compose==1.22.0 awsebcli==3.7.8 && \
rm -rf /var/cache/apk/*
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["sh"]