2016-08-09 97 views
3

我必須在Jenkins上設置一個工作來構建Android應用程序。我還有一個SonarQube服務器,可通過http://x.x.x.198/sonar訪問。 我添加了一個shell腳本,將被調用來啓動項目的聲納分析。 SonarQube服務器和Jenkins運行在不同的服務器上,我可以從Jenkins機器訪問SonarQube主機。Jenkins gradle sonarQube Android

構建失敗,這裏是控制檯輸出:

./gradlew sonarqube --stacktrace -Dsonar.url.host=http://x.x.x.198/sonar 

Parallel execution with configuration on demand is an incubating feature. 
Incremental java compilation is an incubating feature. 
:app:sonarqubeSonarQube server [http://x.x.x.198/sonar] can not be reached 
FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: 
Execution failed for task ':app:sonarqube'. 
> Unable to execute SonarQube 

* Try: 
Run with --info or --debug option to get more log output. 

* Exception is: 
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:sonarqube'. 
    at  org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) 
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) 
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) 
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) 
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) 
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) 
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) 
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) 
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) 
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) 
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) 
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) 
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) 
Caused by: org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube 
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84) 
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71) 
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71) 
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67) 
    at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218) 
    at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156) 
    at org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:83) 
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) 
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227) 
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220) 
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209) 
    at  org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585) 
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568) 
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) 
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) 
    ... 14 more 
Caused by: java.lang.IllegalStateException: Fail to download libraries from server 
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:93) 
    at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70) 
    at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39) 
    at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75) 
    ... 28 more 
Caused by: java.lang.IllegalStateException: Status returned by url [http://10.133.64.198/sonar/batch_bootstrap/index] is not valid: [403] 
    at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:116) 
    at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99) 
    at org.sonarsource.scanner.api.internal.Jars.downloadFiles(Jars.java:78) 
    ... 31 more 


BUILD FAILED 

Total time: 1.632 secs 
Build step 'Execute shell' marked build as failure 
Finished: FAILURE 

有沒有人已經面臨這個問題?需要幫助:|

在此先感謝。

回答

2

Finaly發現爲什麼這是行不通的。在我的gradle.properties中,我已經指定了一些代理屬性。我刪除了這些條目(主機,端口,登錄名,密碼等),因此在調用sonarqube任務時,gradle不會使用任何代理來訪問SonarQube服務器。 Jenkins的任務成功完成,分析報告上傳到sonarqube服務器:)。

這個帖子讓我Sonarqube grade build failed with "SonarQube server [http://x.12.11.18:9000] can not be reached"

希望這能幫助別人。

0

2.7.1 is not back-compatible。在你的pom.xml鎖定你的插件版本2.6或升級SonarQube

解決方法:添加-Dsonar.host.url=http://my.server:9000到MVN命令對我的作品

比禁用插件更好,你可以修復插件版本 2.6,它工作正常,考慮到sonar.host.url。

例如,與Maven在我的情況:

<pluginManagement> 
    </plugins> 
    <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>sonar-maven-plugin</artifactId> 
     <version>2.6</version> 
     <!-- sonar.host.url not working with version 2.7 --> 
    </plugin> 
    </plugins> 
</pluginManagement> 
+0

我正在使用gradle,而不是使用maven。那麼我怎麼能用gradle鎖定插件版本? – black4bird