SonarQube Ant 任务,下载文件失败

SonarQube Ant task, failed to download the file

我是运行一个简单的SonarQube Ant脚本,出现以下错误:

FileNotFoundException: C:\Users\c5187668\sap\simpleAnt.sonar\batch\sonar-batch-maven-compat-5.1.2.jar|99845a2f47eaef85b29978725f82c50c"

它能以某种方式修复吗?有什么想法吗?

Ant 脚本:

<project name="sonar build" default="Sonar" basedir="." xmlns:sonar="antlib:org.sonar.ant">

<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
    <classpath path="sonar-ant-task.jar"/>
</taskdef>
<!-- Out-of-the-box those parameters are optional -->
<property name="sonar.jdbc.url" value="dbc:mysql://?????:3306/sonardb?useUnicode=true;characterEncoding=utf8" />
<property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
<property name="sonar.jdbc.username" value="?????" />
<property name="sonar.jdbc.password" value="?????" />
<!-- Additional Sonar configuration (PMD need 1.5 when using annotations)-->
<property name="sonar.java.source" value="1.6"/>
<property name="sonar.java.target" value="1.6"/>    
<property name="sonar.projectName" value="SonarBuild"/>
<property name="sonar.projectVersion" value="2.0" />
<!-- SERVER ON A REMOTE HOST -->
<property name="sonar.host.url" value="http://??????" />
<target name="Sonar">
    <sonar:sonar />
</target>

我收到以下错误:

BUILD FAILED C:\Users\c5187668\sap\simpleAnt\build.xml:17:
java.lang.IllegalStateException: Fail to download libraries from
server
        at org.sonar.runner.Bootstrapper.downloadBatchFiles(Bootstrapper.java:166)
        at org.sonar.runner.Bootstrapper.createClassLoader(Bootstrapper.java:89)
        at org.sonar.runner.Runner.createClassLoader(Runner.java:229)
        at org.sonar.runner.Runner.execute(Runner.java:151)
        at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:93)
        at org.sonar.ant.SonarTask.execute(SonarTask.java:75)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:435)
        at org.apache.tools.ant.Target.performTasks(Target.java:456)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
        at org.apache.tools.ant.Main.runBuild(Main.java:853)
        at org.apache.tools.ant.Main.startAnt(Main.java:235)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112) Caused
by: java.lang.IllegalStateException: Fail to download the file:
http://???????/batch/sonar-batch-maven-compat-5.1.2.jar|99845a2f47eaef85b29
978725f82c50c

        at org.sonar.runner.Bootstrapper.remoteContentToFile(Bootstrapper.java:115)
        at org.sonar.runner.Bootstrapper.downloadBatchFiles(Bootstrapper.java:161)
        ... 22 more Caused by: java.io.FileNotFoundException: C:\Users\c5187668\sap\simpleAnt\.sonar\batch\sonar-batch-maven-compat-5.1.2.jar|99845a2f47eaef85b29978725f82c50c
(The filename, directory name, or volume label syntax is incorrect)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
        at org.sonar.runner.Bootstrapper.remoteContentToFile(Bootstrapper.java:109)
        ... 23 more

Total time: 0 seconds

P.S。用问号??????我隐藏了真实的服务器名称和凭据。

你告诉 Ant 你的 SonarQube 服务器是 运行 在 http://?????? ,因此脚本无法(完全可以理解)从中下载它需要的资源服务器。

解决这个问题:

<property name="sonar.host.url" value="http://??????" />

该值应该是您用来浏览 SonarQube 服务器主页的 URL。

P.S.: 你还必须修复 sonar.jdbc.usernamesonar.jdbc.password

您的 Ant Task 版本 (2.0) 与您的 SonarQube 版本不兼容。 compatibility matrix 表明 v2.2 是自 SonarQube 3.7 以来的最低要求(2.4 是 SonarQube 4.5+ 的最佳选择)。

你应该升级你的SonarQube Scanner for Ant and also use a supported version of Java