Jenkins-Sonar在Openshift上的交流 [英] Jenkins-Sonar communication on Openshift

查看:65
本文介绍了Jenkins-Sonar在Openshift上的交流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于Jenkins和Sonar进行开发. 两者都放在隔离的齿轮上.

I am making a development environnement based on Jenkins and Sonar. Both are placed on isolated gears.

Jenkins装备是使用Instant App选项创建的. 借助这些github指示创建了Sonar齿轮.

The Jenkins gear has been created with the Instant App option. The Sonar gear has been created thanks to these github indications.

为了分析Maven项目,我创建了Jenkins自由式工作. 该作业上使用的脚本是基于 wordpress文章. /p>

I created a Jenkins free-style job in order to analysis a Maven project. The script used on that job is based on this wordpress article.

# Build script of the Job
settingsPath=$OPENSHIFT_DATA_DIR/settings.xml
settings="<settings>\n   <localRepository>$OPENSHIFT_DATA_DIR</localRepository>\n</settings>\n"
echo $settings > $settingsPath

# Cleaning of the workspace
mvn --global-settings $settingsPath clean test
# Preparation of Sonar informations    
export SONAR_JDBC="-Dsonar.jdbc.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/sonar?useUnicode=true&characterEncoding=utf8"
export SONAR_DRIVER=-Dsonar.jdbc.driver=com.mysql.jdbc.Driver
export SONAR_DBUSER=-Dsonar.jdbc.username=xxx
export SONAR_DBPASS=-Dsonar.jdbc.password=xxx
export SONAR_URL=-Dsonar.host.url=http://sonar-alc.rhcloud.com
export SONAR_OPTS="$SONAR_JDBC $SONAR_DRIVER $SONAR_DBUSER $SONAR_DBPASS $SONAR_URL"
# Sonar analysis
mvn --global-settings $settingsPath sonar:sonar $SONAR_OPTS

在执行mvn sonar:sonar命令时,出现以下错误:

On the execution of the mvn sonar:sonar command, I have the following error:

Can not execute SonarQube analysis: Fail to connect to database: Cannot create PoolableConnectionFactory (Communications link failure

这是与此错误对应的堆栈跟踪:

Here is the stacktrace corresponding to this error:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building ClientEvalcolor 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- sonar-maven-plugin:2.1:sonar (default-cli) @ ClientEvalcolor ---
[INFO] SonarQube version: 3.3.1
[INFO] [03:28:09.324] Create JDBC datasource for jdbc:mysql://xxx.xxx.xxx.xxx:3306/sonar?useUnicode=true&characterEncoding=utf8
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.634s
[INFO] Finished at: Mon Nov 25 03:28:10 EST 2013
[INFO] Final Memory: 12M/182M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project ClientEvalcolor: Can not execute SonarQube analysis: Fail to connect to database: Cannot create PoolableConnectionFactory (Communications link failure
[ERROR] 
[ERROR] The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.): No route to host
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我知道无法从远程服务器访问Openshift mysql数据库,但是Sonar似乎可以在Openshift上运行,而我先前链接的文章成功地做到了这一点.

I know that an Openshift mysql database isn't accessible from a remote server, but Sonar seems to be runnable on Openshift, and the article that I previously linked successfully did it.

您对如何解决该问题有任何想法吗?

Do you have any idea about how to fix that ?

谢谢你, 阿尔瓦罗(Alvaro C.)

Thank you, Alvaro C.

推荐答案

我终于成功地使我的Jenkins装备向我的Sonar装备发送了数据!

I finally succeeded on making my Jenkins gear send data to my Sonar gear !

我将解释我在这里找到的解决方案,也许它将对某些人有所帮助.

I'll explain the solution I found here, maybe it will help some people.

有三种方法可以访问Openshift数据库:

There a three ways to access an Openshift database:

  1. 包含该数据库的设备可以在localhost:3306上轻松访问它.这是通常的情况.
  2. 您可以在自己的计算机上(使用rhc工具)绑定端口以访问数据库.这不能从其他齿轮应用,并且需要rhc工具保持运行.
  3. 您帐户中的任何装备都可以访问可扩展应用程序的数据库.

用法:

在创建Sonar齿轮时,必须将齿轮设置为可缩放(詹金斯/diy齿轮无法做到).向此齿轮添加数据库盒带将消耗1齿轮,但是可以从任何Openshift应用程序访问此数据库.

When creating the Sonar gear, it's necessary to set the gear as scalable (this can't be done with jenkins/diy gears). Adding a database cartridge to this gear will consume 1 gear, but this database can be accessed from any Openshift application.

请注意,此新数据库的端口将不同于3306(在我的情况下为39536).如果您没有此功能,则可能是嵌入式应用程序未设置为可扩展的.

Notice that this new database will have a port different than 3306 (in my case, 39536). If you don't have this, that's probably that the embedded app isn't set scalable.

我在问题中输入的Jenkins工作脚本是正确的.更改所有这些"xxxxx"和端口以及您的数据库信息将使Jenkins能够完成他的工作!

The Jenkins job script that I put in my question is correct. Changing all these "xxxxx" and the port with your database info will permit Jenkins to do his job !

这篇关于Jenkins-Sonar在Openshift上的交流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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