声纳插件不适用于使用 ANT 作为构建脚本的项目 [英] Sonar plugin not working for projects that use ANT as a build script

查看:35
本文介绍了声纳插件不适用于使用 ANT 作为构建脚本的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

我刚刚安装了 Sonar Jenkins 插件.我进入了我配置的工作(一个自由风格的工作),它通过 ANT 构建生成一个 WAR 文件工件,并执行如下操作:

I have just installed the Sonar Jenkins plugin. I went into my configured job (a free style job) that produces a WAR file artifact through an ANT build and did as follows:

  1. 选中声纳复选框.(这里没有问题)

  1. Check the Sonar checkbox. (No problems here)

配置sonar的安装目录(这里没问题)

Configure the install dir of sonar (No problems here)

选中以下复选框:检查这个项目是否不是用 maven 2 构建的"(我在这里很困惑)

Checked the checkbox that states: "Check if this project is NOT built with maven 2" (I am confused here)

我选中了那个框,因为我没有使用 maven 进行构建,我使用的是 ANT 但它仍然要求我提供类似于很多 MVN 的必需属性,例如:组织 ID、项目 ID、项目名称、项目版本、源目录……等等……

I have checked that box because I am not using maven for build, I am using ANT but it still asked me for required properties that resemble a lot MVN such as: Organization id, project id, project name, project version, source directories... etc..

所以我也填写了这些.当我点击播放按钮立即构建"时,构建似乎运行良好,就像安装声纳之前一样,但最终失败了,因为它试图执行 MAVEN.

So I have filled those as well. When I click the play button "Build Now" the build seems to be running fine as it always had prior to sonar installation but it fails at the very end because its trying to execute MAVEN.

如下:

$ mvn -f/root/.jenkins/jobs/HRDA/workspace/pom.xml -e -B sonar:sonar致命:命令执行失败java.io.IOException:无法运行程序mvn"(在目录/root/.jenkins/jobs/HRDA/workspace"中):java.io.IOException:error=2,没有那个文件或目录

问题

  1. 如果我选中了说如果您使用 Maven 2 的复选框,那么为什么 Sonar 会尝试执行 Maven?

  1. Why is Sonar trying to execute Maven if I have checked the box that said check this box if you do NOT use Maven 2?

如果我的应用是使用 ANT、GANT、GRADLE 构建的,我可以使用这个 Sonar 插件吗?

Can I make use of this Sonar plugin if my apps are built with ANT, GANT, GRADLE?

我是否必须重新转换我的应用才能使用 MVN 版本?

Do I have to reconvert my apps to use MVN builds?

谢谢,- 达里奥

推荐答案

就像 Oers 在我的问题评论中建议的那样,如果您在 CI 服务器(在我的情况下为 Jenkins)中使用 ANT 作为构建脚本,您将不得不使用 SONAR-ANT-TASK 生成 Sonar 报告,操作如下:

Like Oers suggested on my question comments if you are using ANT as a build script in your CI server (Jenkins in my case) you will have to use the SONAR-ANT-TASK to generate Sonar reports, do as follows:

  1. 下载 MySQL 或任何其他声纳支持的 RDBMS,例如 Postgres、Oracle 等.'
  2. 下载并安装声纳服务器.
  3. 转到(声纳安装文件夹)/extras/database/mysql 并运行 create_database.sql 脚本.
  4. 在我的情况下,我必须使用 mysql 运行一个额外的 sql 语句,您可以在这里看到 无法访问 Sonar MySQL 数据库 原因:java.sql.SQLException:用户 'sonar'@'glassfishdev.ccs.local' 访问被拒绝(使用密码:是)
  5. 输入 ./sonar.sh start 启动声纳
  6. 将声纳蚂蚁任务添加到您的构建脚本中.你可以按照这个模板http://docs.codehaus.org/display/SONAR/Analyse+with+Ant+Task+1.0
  7. 不要如果您安装了 Hudson Sonar 插件,请选中配置"屏幕中的声纳复选框,因为此插件仅适用于 Maven 项目.
  8. 点击立即构建"按钮.如果以上一切都正确完成,您应该能够在 http://ipaddressofmachinesonarisinstalled:9000/
  1. Download MySQL or any other Sonar supported RDBMS such as Postgres, Oracle, etc..'
  2. Download and Install sonar server.
  3. go to (sonar installation folder)/extras/database/mysql and run the create_database.sql script.
  4. I had to run an extra sql statement in my case using mysql, you can see here Unable to access Sonar MySQL database Caused by: java.sql.SQLException: Access denied for user 'sonar'@'glassfishdev.ccs.local' (using password: YES)
  5. Start Sonar by typing ./sonar.sh start
  6. Add the sonar ant task to your build script. You can follow this template http://docs.codehaus.org/display/SONAR/Analyse+with+Ant+Task+1.0
  7. DO NOT check the sonar check box in your Configure screen if you have the Hudson Sonar plugin for installed, as this plugin only works with Maven projects.
  8. Click the "Build Now" button. If everything above has been done correctly you should be able to see the reports at http://ipaddressofmachinesonarisinstalled:9000/

希望这有帮助,-达里奥

Hope this helps, -Dario

这篇关于声纳插件不适用于使用 ANT 作为构建脚本的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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