原因:java.lang.IllegalStateException:文件夹 'test' 不存在

Caused by: java.lang.IllegalStateException: The folder 'test' does not exist for

我需要你的帮助。 这是上下文,我正在尝试设置一个持续集成平台,以满足特定需求,这是我的配置,都在同一台机器上(Windows 7):

当我从 Jenkins 启动构建时出现此错误:

NFO: Work directory: C:\Users\user\.jenkins\jobs\test projet\workspace\.sonar
INFO: SonarQube Server 5.1.2
14:13:10.295 INFO  - Load global repositories
14:13:10.372 INFO  - Load global repositories (done) | time=78ms
14:13:10.374 INFO  - Server id: 20151028133512
14:13:10.374 INFO  - User cache: C:\Users\user\.sonar\cache
14:13:10.379 INFO  - Install plugins
14:13:10.706 INFO  - Install JDBC driver
14:13:10.710 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
14:13:11.247 INFO  - Initializing Hibernate
14:13:12.106 ERROR - Invalid value of sonar.tests for my:project
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2.131s
Final Memory: 6M/20M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: The folder 'test' does not exist for 'my:project' (base directory = C:\Users\user\.jenkins\jobs\test projet\workspace)
    at org.sonar.batch.scan.ProjectReactorBuilder.checkExistenceOfPaths(ProjectReactorBuilder.java:427)
    at org.sonar.batch.scan.ProjectReactorBuilder.validateDirectories(ProjectReactorBuilder.java:334)
    at org.sonar.batch.scan.ProjectReactorBuilder.defineRootProject(ProjectReactorBuilder.java:163)
    at org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:116)
    at org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:110)
    at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:86)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.sonar.runner.impl.BatchLauncher.delegateExecution(BatchLauncher.java:87)
    ... 9 more
ERROR: 
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Lancer une analyse SonarQube autonome' marked build as failure
Finished: FAILURE

我按照这些步骤来确定根本问题:

  1. 我手动创建了sonar-project.properties.
  2. Lunch sonar-runner.bat 直接从我的 php 文件夹中,=> 然后它完美地工作我有所有的指标。
  3. 我确定根本原因是 Jenkins,但我不知道我到底错过了什么。

即使有时一切似乎都正常,我还是从堆栈跟踪中收到了这条消息

0 file indexed

:

     INFO: Error stacktraces are turned on.
INFO: Runner configuration file: C:\DevTools\sonar-runner-2.4\conf\sonar-runner.properties
INFO: Project configuration file: C:\Users\user\Desktop\Exemple de projet PHPUNIT\sonar-project.properties
INFO: Default locale: "fr_FR", source code encoding: "UTF-8"
INFO: Work directory: C:\Users\user\.jenkins\jobs\projet\workspace\.sonar
INFO: SonarQube Server 5.1.2
14:55:20.977 INFO  - Load global repositories
14:55:21.040 INFO  - Load global repositories (done) | time=63ms
14:55:21.040 INFO  - Server id: 20151028133512
14:55:21.040 INFO  - User cache: C:\Users\user\.sonar\cache
14:55:21.040 INFO  - Install plugins
14:55:21.390 INFO  - Install JDBC driver
14:55:21.390 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
14:55:21.918 INFO  - Initializing Hibernate
14:55:22.858 INFO  - Load project repositories
14:55:23.030 INFO  - Load project repositories (done) | time=172ms
14:55:23.030 INFO  - Load project settings
14:55:23.326 INFO  - Load technical debt model
14:55:23.358 INFO  - Apply project exclusions
14:55:23.498 WARN  - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project.
14:55:23.498 INFO  - -------------  Scan My Sonar Analyses for PHP project
14:55:23.498 INFO  - Load module settings
14:55:23.576 INFO  - Language is forced to php
14:55:23.576 INFO  - Load rules
14:55:23.864 INFO  - Base dir: C:\Users\user\.jenkins\jobs\projet\workspace
14:55:23.864 INFO  - Working dir: C:\Users\user\.jenkins\jobs\projet\workspace\.sonar
14:55:23.864 INFO  - Source paths: .
14:55:23.864 INFO  - Source encoding: UTF-8, default locale: fr_FR
14:55:23.864 INFO  - Index files
14:55:23.866 INFO  - **0 files indexed******************************
14:55:23.866 INFO  - Quality profile for php: Sonar way
14:55:24.095 INFO  - Sensor Lines Sensor
14:55:24.095 INFO  - Sensor Lines Sensor (done) | time=0ms
14:55:24.095 INFO  - Sensor QProfileSensor
14:55:24.105 INFO  - Sensor QProfileSensor (done) | time=10ms
14:55:24.105 INFO  - Sensor InitialOpenIssuesSensor
14:55:24.120 INFO  - Sensor InitialOpenIssuesSensor (done) | time=15ms
14:55:24.120 INFO  - Sensor ProjectLinksSensor
14:55:24.128 INFO  - Sensor ProjectLinksSensor (done) | time=8ms
14:55:24.128 INFO  - Sensor VersionEventsSensor
14:55:24.133 INFO  - Sensor VersionEventsSensor (done) | time=5ms
14:55:24.133 INFO  - Sensor SCM Sensor
14:55:24.133 INFO  - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
14:55:24.133 INFO  - Sensor SCM Sensor (done) | time=0ms
14:55:24.133 INFO  - Sensor CPD Sensor
14:55:24.133 INFO  - DefaultCpdEngine is used for php
14:55:24.133 INFO  - Sensor CPD Sensor (done) | time=0ms
14:55:24.133 INFO  - No quality gate is configured.
14:55:24.163 INFO  - Compare to previous analysis (2015-10-28)
14:55:24.165 INFO  - Compare over 30 days (2015-09-28, analysis of Wed Oct 28 14:39:55 CET 2015)
14:55:24.267 INFO  - Execute decorators...
14:55:24.372 INFO  - Store results in database
14:55:24.425 INFO  - Analysis reports generated in 35ms, dir size=2 KB
14:55:24.435 INFO  - Analysis reports compressed in 10ms, zip size=2 KB
14:55:24.459 INFO  - Analysis reports sent to server in 23ms
14:55:24.460 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/projet
14:55:24.460 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 3.851s
Final Memory: 13M/113M
INFO: ------------------------------------------------------------------------
Finished: SUCCESS

他似乎可以索引我 php 文件夹中的文件。 预先感谢您的帮助!

我找到了根本原因,正如我在上一条评论中所建议的那样,Jenkis 是根本问题,因为我不知道 Jenkins 如何构建非源代码控制项目。 事实上,您必须按照这些步骤将您的项目复制到 Jenkis 工作区中:

  1. 至少构建一次项目,(它会失败),但 Jenkins 会 创建结构 jenkins/workspace/PROJECTNAME/
  2. 将项目文件复制到jenkins/workspace/PROJECTNAME/
  3. 再次构建并适当配置

有关该主题的更多信息,我建议您查看 jenkins 文档:Builds for Non-Source Control Projects