在jenkins插件中正确设置sonar.sources [英] correctly setting sonar.sources in jenkins plugin

查看:3510
本文介绍了在jenkins插件中正确设置sonar.sources的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个 Android Java项目分支:feature-Fprototype_app

I am trying to build an Android java project branch: feature-Fprototype_app

我收到此错误:

[INFO] [13:38:36.470] Base dir: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile 
[INFO] [13:38:36.470] Working dir: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/target/sonar 
[INFO] [13:38:36.470] Source dirs: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src 
[INFO] [13:38:36.470] Binary dirs: /Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/target/classes 
[INFO] [13:38:36.470] Source encoding: UTF-8, default locale: en_US 
[INFO] [13:38:36.489] Sensor JavaSourceImporter... 
[INFO] [13:38:36.710] Sensor JavaSourceImporter done: 221 ms 
[INFO] [13:38:36.710] Sensor JavaSquidSensor... 
[INFO] [13:38:36.800] Java AST scan... 
[ERROR] Sonar is unable to analyze file : '/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src/main/java/com/simpragma/apps/textify/db/BookmarkDao.java' 
[INFO]
    ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------- 
[INFO] Total time:14.245s 
[INFO] Finished at: Thu Oct 17 13:38:36 GMT+05:30 2013 
[INFO] Final Memory: 14M/102M 
[INFO]
    ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project Textify: Can not execute SonarQube analysis: Sonar is unable to analyze file :

    **'/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src/main/java/com/simpragma/apps/textify/db/BookmarkDao.java': The source directory does not correspond to the package declaration** com.simpragma.apps.textify.db -> 
[Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project Textify: Can not execute SonarQube analysis

在jenkins配置中,构建后操作我试图在其他属性框中设置sonar.sources(因为当我搜索错误时,人们建议设置正确的来源路径).我尝试了很多组合,例如:

In jenkins configuration Post Build Action I am trying to set the sonar.sources in Additional properties box (because when i googled for the error, people suggested to set the correct path for sources). I tried many combinations like:

 -Dsonar.sources=mobile/src/main/java
 -Dsonar.sources=/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile/src/main/java
 -Dsonar.sources=/Users/Shared/Jenkins/Home/jobs/Textify/workspace/mobile

仍然相同的错误. 我在做什么错了?

still same error. What am I doing wrong ?

好,让我清除一下我创建的烂摊子.首先,这是一个android maven项目.包结构为com.xyz.abc,源根为src/main/java.在pom.xml中, sourceDirectory 属性最初设置为指向 src .看来maven与source的根目录没有任何问题,它正在编译项目. 然后,我为此项目设置了詹金斯和声纳.我使用了詹金斯(Jenkins)的构建后行动来对我的项目进行声纳分析.这里的问题是使用Maven运行分析时,某些SonarQube属性始终会被忽略,因为SonarQube在内部从POM馈送它们"- SONAR-4536 .此类属性之一是 sonar.sources .因此,当我在Jenkins安装程序中尝试使用-Dsonar.sources时,它没有工作. 后来,我将pom修改为指向src/main/java,从而通过jenkins的构建后操作成功进行了分析.

ok let me clear the mess I have created. Firstly, it is an android maven project. The package structure is com.xyz.abc and source root was src/main/java. In pom.xml the sourceDirectory property was initially set to point to src. It seems maven does not have any issue with the root of source, it is compiling the project. Then, I set up jenkins and sonar for this project. I used Jenkins's Post-build Action to set up Sonar analysis on my project. The catch here is "When running an analysis with Maven, some SonarQube properties are always ignored because SonarQube internally feeds them from the POM" - SONAR-4536. One among such properties is sonar.sources . Therefore, when i tried with -Dsonar.sources in the Jenkins setup it did not worked. Later I modified my pom to point to src/main/java which resulted in successful analysis through jenkins post-build action.

我希望我已经澄清了.

推荐答案

如果您的项目是Maven项目,并且您正在使用SonarQube Maven插件,则源位置将从Maven模型获取.仅在使用SonarQube Runner执行分析时才使用sonar.sources属性.

If your project is a Maven project and you are using SonarQube Maven plugin then source location is taken from Maven model. The property sonar.sources is only used when using SonarQube Runner to perform the analysis.

查看您的项目pom.xml并检查.另外,请更新您的问题,以告诉您是在常规Java项目还是其他项目(例如android)上.

Look at your project pom.xml and check . Also please update your question to tell if you are on a regular Java project or anything else (like android).

这篇关于在jenkins插件中正确设置sonar.sources的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆