Home Database Mysql Tutorial 集成环境搭建及遇到的问题 jetty8+hudson2.2.0+sonar2.11+mysql5

集成环境搭建及遇到的问题 jetty8+hudson2.2.0+sonar2.11+mysql5

Jun 07, 2016 pm 03:47 PM
introduce build Overview environment detailed meet question integrated

一、概述 笔者将详细介绍集成环境搭建及需要注意的事项。此些点都摸索了许多天完成的。一些问题是在搭建过程中实际遇到过的。当然大多数都是环境配置的问题。如果遇到集成环境的一些问题,欢迎和笔者联系。笔者很愿意与大家交流。 二、背景知识 为什么要集成

一、概述

笔者将详细介绍集成环境搭建及需要注意的事项。此些点都摸索了许多天完成的。一些问题是在搭建过程中实际遇到过的。当然大多数都是环境配置的问题。如果遇到集成环境的一些问题,欢迎和笔者联系。笔者很愿意与大家交流。

二、背景知识

为什么要集成环境。当然是为了代码质量。通过不断地集成来提高代码的质量。检查代码质量有两种方式。第一种是,静态测试:包括:codereview、静态代码检测技术等;第二种是,动态测试:包括:单元测试,接口测试,UI测试,人工点页面等测试。静态代码分析是指无需运行被测代码,仅通过分析或检查源程序的语法、结构、过程、接口等来检查程序的正确性,找出代码隐藏的错误和缺陷,如参数不匹配,有歧义的嵌套语句,错误的递归,非法计算,可能出现的空指针引用等等。在软件开发过程中,静态代码分析往往先于动态测试之前进行,同时也可以作为制定动态测试用例的参考。统计证明,在整个软件开发生命周期中,30% 至 70% 的代码逻辑设计和编码缺陷是可以通过静态代码分析来发现和修复的。

三、软件介绍及准备

我们主要用到 hudson、sonar、Jetty 、MySQL开源软件。这些全部都是开源软件。我简短介绍下,大家可以到它们的主页去详细了解。

  • Hudson 是一个可扩展的持续集成引擎。主要用于持续、自动地构建/测试软件项目。
  • Sonar是一个开源平台,用于管理Java源代码的质量。从 Sonar 1.6 版本开始,Sonar从一个质量数据报告工具,转变成为现在的代码质量管理平台。
  • Jetty 是一个开源的servlet容器,它为基于Java的web内容,例如JSP和servlet提供运行环境。Jetty是使用Java语言编写的,它的API以一组JAR包的形式发布。开发人员可以将Jetty容器实例化成一个对象,可以迅速为一些独立运行(stand-alone)的Java应用提供网络和web连接。
  • MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQL AB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。现在有许多大公司也考虑这一构架。

三、架构介绍

我们需要三台逻辑上服务器,当然都可以在一个机器上面。就是 HUDSON、SONAR、MYSQL。关系如下图所示:

集成环境搭建及遇到的问题 jetty8+hudson2.2.0+sonar2.11+mysql5

我们架构图大致如下所示:

集成环境搭建及遇到的问题 jetty8+hudson2.2.0+sonar2.11+mysql5


HUDSON与SONAR集成起来是用HUDSON上面的一个sonar插件。所有的命令都是用mvn来做的。

三、软件准备及相关系统配置(所有的下载地址都是目前有效的,以后就不保证了哦)

  • JAVA、MAVEN请先配置好。
  • JETTY,我们需要从http://wiki.eclipse.org/Jetty/Howto/Install_Jetty下载,下载地址如下。无需配置。
  • wget http://dist.codehaus.org/jetty/jetty-hightide-8.0.0/jetty-hightide-8.0.0.v20110901.tar.gz
    tar xfz jetty-hightide-8.0.0.v20110901.tar.gz
    Copy after login
  • HUDSON,http://hudson-ci.org/   因为是一个war包,我们也不可在代码中配置,配置都在页面。需要把hudson-2.1.2.war重名为hudson.war,再拷到jetty的webapps目录下。
  • wget http://java.net/projects/hudson/downloads/download/war/hudson-2.1.2.war
    Copy after login
  • SONAR,http://www.sonarsource.org/downloads/  需要配置conf/sonar.properties文件。
  • wget http://dist.sonar.codehaus.org/sonar-2.11.zip
    unzip sonar-2.11.zip
    Copy after login
    要注意,不可重复,url编码设置为utf8
    sonar.jdbc.username:                       sonar
    sonar.jdbc.password:                      sonar 
    sonar.jdbc.url:                            jdbc:mysql://10.20.155.8:3306/sonar?useUnicode=true&characterEncoding=utf8
    sonar.jdbc.driverClassName:                com.mysql.jdbc.Driver
    sonar.jdbc.validationQuery:                select 1
    Copy after login
  • MYSQL,这里需要你对mysql数据库有一定的认识。知道基本的编码问题及访问权限问题。以下简单列出一些配置。
  • su root
    wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-5.5.17-1.linux2.6.x86_64.tar/from/http://ftp.iij.ad.jp/pub/db/mysql/
    tar xf MySQL-5.5.17-1.linux2.6.i386.tar
    rpm -i MySQL-server-5.5.17-1.linux2.6.x86_64.rpm 
    rpm -i MySQL-client-5.5.17-1.linux2.6.x86_64.rpm 
    
    Copy after login
    修改配置:
    cp /usr/share/doc/MySQL-server-5.5.17/my-large.cnf /etc/my.cnf
    vi /etc/my.cnf
    在[client]下面加上 default-character-set = utf8
    在[mysqld]下面加上 character-set-server=utf8  init_connect = 'SET NAMES utf8'
    启动:/etc/init.d/mysql start 
    登陆:mysql -h localhost -u root -p
    修改密码:/usr/bin/mysqladmin -u root -h vm-qa-crm-155-8.hst.bjc.kfc.alidc.net password 'new-password'
    mysql>  SHOW VARIABLES LIKE 'character_set_%';
    +--------------------------+----------------------------+
    | Variable_name            | Value                      |
    +--------------------------+----------------------------+
    | character_set_client     | utf8                       |
    | character_set_connection | utf8                       |
    | character_set_database   | utf8                       |
    | character_set_filesystem | binary                     |
    | character_set_results    | utf8                       |
    | character_set_server     | utf8                       |
    | character_set_system     | utf8                       |
    | character_sets_dir       | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.00 sec)
    mysql> create database sonar 
    也可以用 Navicat for MySQL 等创建 数据库等。
    
    Copy after login

五、HUDSON相关配置及编译流程

把相关服务启动后,包括jetty、sonar、mysql。就可以访问hudson(http://10.20.155.8:8080/hudson/)与sonar (http://10.20.155.8:9000/)。

大致我们的配置流程与每个阶段运行的代码(这些代码都是配置在hudson上面的,下面会给出配置的位置):

集成环境搭建及遇到的问题 jetty8+hudson2.2.0+sonar2.11+mysql5

  • 准备测试环境:mvn -f all/pom.xml clean install  -Dmaven.test.skip
  • 单元测试: mvn -f all/pom.xml cobertura:cobertura -Dcobertura.report.format=xml
  • 静态检测: mvn -all/pom.xml -Dsonar.sourceEncoding=GBK -Dsonar.dynamicAnalysis=reuseReports -e -B sonar:sonar -Dsonar.jdbc.driver=com.mysql.jdbc.Driver -Dsonar.jdbc.url=jdbc:mysql://10.20.155.8:3306/sonar?autoReconnect=true&useUnicode=true&characterEncoding=utf8 ******** ******** -Dsonar.host.url=http://10.20.155.8:9000

HUDSON的配置:

  • 下载相关的最新版插件 Hudson Cobertura plugin (目前1.1)、Jenkins Sonar Plugin(目前1.7.1)。
  • 在hudson系统设置中指定好相关的JAVA、MAVEN,也可以在 .bash_profile 文件中配置JAVA_HOME、MAVEN_HOME
  • 配置好sonar插件的一些属性
  • 集成环境搭建及遇到的问题 jetty8+hudson2.2.0+sonar2.11+mysql5
  •  新建任务,设置 ,配置如下(只有一些重要的):
    • Source Code Management选择svn,填写好分支。
    • Build Triggers 做好适合自己的触发模式
    • Build 填写好 如下图所示:
    • 集成环境搭建及遇到的问题 jetty8+hudson2.2.0+sonar2.11+mysql5
    • Post-build Actions里面设置后续的操作:
      • Publish Cobertura Coverage Report :Cobertura xml report pattern填写他推荐的:**/target/site/cobertura/coverage.xml 。其他的不变
      • Sonar:POM填写你的pom.xml
  • 恭喜您,做完以上的一些,大致就可以跑起来了。也能在mysql数据库中看到sonar的表。如果还没有成功请看看常见问题列表。如果没有,请留言,我尽力帮助您。

六、常见的一些问题

  1. 找不到mysql的驱动。
    1. 这个需要在sonar配置mysql数据库。上面已经配置了。
  2. 源码在存入数据库的时候报错。错误为:[ERROR]  Incorrect string value: '\xF2\xB7\xB5\xBB\xEF\xBF...' for column 'data' at row 1   ....  Caused by: java.sql.SQLException: Incorrect string value: '\xF2\xB7\xB5\xBB\xEF\xBF...' for column 'data' at row 1
    • 这个错误就是这些字符不能插入到数据库中。这个肯定就是编码的问题了。源文件不能插入到数据库中。
    • 过程为:
      • 从本地磁盘中读出 文件,此涉及到解码。如果存储的文件编码为GBK那么读文件的时候也要设置成GBK。
      • 把内存中的对象转化成流存储到数据中。此涉及到网络传输的问题。我们必须编码与解码一致。如:client是utf8那么数据库也要用这个utf8
    • 这个问题大部分的文件是,要读取文件的时候,解码是错误的。我们可以用 -Dsonar.sourceEncoding=GBK 来设定。当然也可能是别的原因,这个需要自己多加分析。
  3. cobertura已经跑完了单元测试,soanr又跑一次单元测试。我们希望只跑一次单元测试。并且结果在hudson上面展示。sonar上面也可以展示。
    1. 我们可以用 cobertura 先跑单元测试,后在跑sonar 的时候 指定参数:-Dsonar.dynamicAnalysis=reuseReports 服用以前的报告。
  4. cobertura不能统计单元测试覆盖率。错误为:No coverage results were found using the pattern '**/target/site/cobertura/coverage.xml' relative to '/home/hudson/.hudson/jobs/finance/workspace'.
    1. 这个需要设置 -Dcobertura.report.format=xml 这个参数,这个也是 cobertura 的参数,默认值为html.

七、参考资料

  • 官方文档搭建文档:http://docs.codehaus.org/display/SONAR/Hudson+and+Jenkins+Plugin
  • cobertura地址:http://mojo.codehaus.org/cobertura-maven-plugin/cobertura-mojo.html (cobertura.report.format = xml )
  • sonar配置项:http://docs.codehaus.org/display/SONAR/Advanced+parameters   (sonar.sourceEncoding = gbk  sonar.dynamicAnalysis = reuseReports)
  • 跳过测试:http://maven.apache.org/plugins/maven-surefire-plugin/examples/skipping-test.html(mvn install -Dmaven.test.skip=true  maven.test.skip)http://maven.apache.org/maven-1.x/plugins/test/properties.html(maven.test.skip )
  • surefire:http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html
  • mysql服务器参数:http://dev.mysql.com/doc/refman/5.5/en/server-options.html
  • hudson相关文档:http://hudson-ci.org/docs/index.html

八、版权申明

  • http://blog.csdn.net/bxyz1203/article/details/6980174
  • 作者:就职于 阿里巴巴 封神


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Introduction to the skills and attributes of Hua Yishan Heart of the Moon Lu Shu Introduction to the skills and attributes of Hua Yishan Heart of the Moon Lu Shu Mar 23, 2024 pm 05:30 PM

In Hua Yishan Heart Moon, Lu Shu is an SSR celebrity. He is positioned as a single-target backline player and has a very impressive critical hit rate. Many players don’t know much about Lu Shu. Here’s what I’ve brought you. Come and take a look at the introduction to the skills and attributes of Hua Yishan Heart of the Moon Lu Shu. Celebrity Attributes Celebrity Skills 1. Lu Ming Shuzhong Skill Description: Lu Shu was born in Qiongqihui in Shuzhong. He has practiced martial arts since he was a child and has outstanding martial arts skills. Causes basic attack damage equal to 100% of the enemy's back row attack power, and reduces the target's rage by 10 points. Skill attributes: Level 2: Basic attack damage increased to 105%. Level 2: Basic attack damage is increased to 110%, and the target's rage is reduced by 15 points. Level 2: Basic attack damage increased to 115%. Level 2: Basic attack damage is increased to 120%, and the target's rage is reduced by 20 points. Level 2: Basic attack

Can buildings be built in the wild in Mistlock Kingdom? Can buildings be built in the wild in Mistlock Kingdom? Mar 07, 2024 pm 08:28 PM

Players can collect different materials to build buildings when playing in the Mistlock Kingdom. Many players want to know whether to build buildings in the wild. Buildings cannot be built in the wild in the Mistlock Kingdom. They must be within the scope of the altar. . Can buildings be built in the wild in Mistlock Kingdom? Answer: No. 1. Buildings cannot be built in the wild areas of the Mist Lock Kingdom. 2. The building must be built within the scope of the altar. 3. Players can place the Spirit Fire Altar by themselves, but once they leave the range, they will not be able to construct buildings. 4. We can also directly dig a hole in the mountain as our home, so we don’t need to consume building materials. 5. There is a comfort mechanism in the buildings built by players themselves, that is to say, the better the interior, the higher the comfort. 6. High comfort will bring attribute bonuses to players, such as

PyCharm Beginner's Guide: Comprehensive Analysis of Replacement Functions PyCharm Beginner's Guide: Comprehensive Analysis of Replacement Functions Feb 25, 2024 am 11:15 AM

PyCharm is a powerful Python integrated development environment with rich functions and tools that can greatly improve development efficiency. Among them, the replacement function is one of the functions frequently used in the development process, which can help developers quickly modify the code and improve the code quality. This article will introduce PyCharm's replacement function in detail, combined with specific code examples, to help novices better master and use this function. Introduction to the replacement function PyCharm's replacement function can help developers quickly replace specified text in the code

Detailed introduction of Samsung S24ai functions Detailed introduction of Samsung S24ai functions Jun 24, 2024 am 11:18 AM

2024 is the first year of AI mobile phones. More and more mobile phones integrate multiple AI functions. Empowered by AI smart technology, our mobile phones can be used more efficiently and conveniently. Recently, the Galaxy S24 series released at the beginning of the year has once again improved its generative AI experience. Let’s take a look at the detailed function introduction below. 1. Generative AI deeply empowers Samsung Galaxy S24 series, which is empowered by Galaxy AI and brings many intelligent applications. These functions are deeply integrated with Samsung One UI6.1, allowing users to have a convenient intelligent experience at any time, significantly improving the performance of mobile phones. Efficiency and convenience of use. The instant search function pioneered by the Galaxy S24 series is one of the highlights. Users only need to press and hold

Oracle API integration strategy analysis: achieving seamless communication between systems Oracle API integration strategy analysis: achieving seamless communication between systems Mar 07, 2024 pm 10:09 PM

OracleAPI integration strategy analysis: To achieve seamless communication between systems, specific code examples are required. In today's digital era, internal enterprise systems need to communicate with each other and share data, and OracleAPI is one of the important tools to help achieve seamless communication between systems. This article will start with the basic concepts and principles of OracleAPI, explore API integration strategies, and finally give specific code examples to help readers better understand and apply OracleAPI. 1. Basic Oracle API

What is Dogecoin What is Dogecoin Apr 01, 2024 pm 04:46 PM

Dogecoin is a cryptocurrency created based on Internet memes, with no fixed supply cap, fast transaction times, low transaction fees, and a large meme community. Uses include small transactions, tips, and charitable donations. However, its unlimited supply, market volatility, and status as a joke coin also bring risks and concerns. What is Dogecoin? Dogecoin is a cryptocurrency created based on internet memes and jokes. Origin and History: Dogecoin was created in December 2013 by two software engineers, Billy Markus and Jackson Palmer. Inspired by the then-popular "Doge" meme, a comical photo featuring a Shiba Inu with broken English. Features and Benefits: Unlimited Supply: Unlike other cryptocurrencies such as Bitcoin

How to build an account matrix? What are the functions of matrix construction? How to build an account matrix? What are the functions of matrix construction? Mar 23, 2024 pm 06:46 PM

In today's information-rich era, social media platforms have become the main way for people to obtain and share information. For individuals and enterprises, establishing an effective account network to achieve maximum dissemination of information and enhance influence has become an urgent challenge that needs to be solved. 1. How to build an account matrix? 1. Clarify the target audience. Before building an account matrix, the key is to clearly define the target audience and gain an in-depth understanding of their needs, interests, and consumption habits, so that a more targeted content strategy can be developed. 2. Choose the appropriate platform. According to the characteristics of the target group, choose the appropriate social media platform for layout. Currently, the mainstream social media platforms include Weibo, WeChat, Douyin, Kuaishou, etc. Each platform has its own unique user groups and communication characteristics, and the selection needs to be based on the actual situation.

Introduction to the eighth color weapon of Neon Abyss Introduction to the eighth color weapon of Neon Abyss Mar 31, 2024 pm 03:51 PM

The eighth color is a weapon in Neon Abyss. Many players want to know about the ballistics of the eighth color of the weapon and how to play with the weapon strength. So let’s take a look at the detailed guide to Neon Abyss’ eighth color weapon trajectory, weapon strength, and weapon gameplay. Neon Abyss Color 8 Detailed Guide Weapon Introduction: The Wizard’s Secret Weapon! Weapon attack speed: Normal Weapon strength: Moderate Weapon gameplay: The attack method of the eighth color is three single-target attacks and then launches a ray. Ballistic display:

See all articles