Continuous integration Java manual

xiaoxiao2021-03-06  49

Continuous integration Java manual

First, concept

Martin Fowler's article: Continent Integration Chinese Translation: Continuous Integration

Second, tools

Traditional tools: Visualstudio.Net, VisualsourceSafe, Rational Clearcase

Auto Compilation Tool: Ant

Return test Tool: JUnit

Code Check Tool: Checkstyle

Continuous integration tool: CruiseControl

Third, step

CruiseControl Monitoring the change of the remote version control system CruiseControl call compilation tool to compile (Ant, etc.) After the compilation is successful, call JUnit to return to the test. After the test is successful, then call the checkStyle After the code check, the results, test results, code check results To developer, supervisor, and publish to the website, even alarm

All this is automatically carried out according to the prepared script

Fourth, the implementation example

At present, we use ClearCase, the master software is CruiseControl, its script file is cccc.xml

Configure a remote version control system

<

Modificationset QuietPeriod

= "

30

">

<

Clearcase

Branch

= "

main

"

ViewPath

= "

D: /cc_view/chelseafc/nucleus2.0/port

"

Recursive

= "

True

"/>

ModificationSet

>

Configure compilation tool

<

Schedule Interval

= "

30

">

<

Ant

Antscript

= "

C: /java/jbuilder2005/thirdparty/ant/bin/ant.bat

"

Buildfile

= "

D: /cc_view/chelseafc/nucleus2.0/port/clearcase-build.xml

"

Target

= "

Cleanbuild

"

Multiple

= "

1

"/>

Schedule

>

Configure test case (in Ant configuration file)

<

Target Name

= "

Test

"

Depends

= "

init

"

Description

= "

Run Unit Tests

">

<

Delete

DIR

= "

$ {junit.results}

"/>

<

Mkdir

DIR

= "

$ {junit.results}

"/>

-

<

Junit Fork

= "

YES

"

HALTONFAILURE

= "

YES

">

-

<

Classpath

>

<

PATHELEMENT

Location

= "

$ {build.dir}

"/>

Classpath

>

<

Formatter

Type

= "

Plain

"

Usefile

= "

False

"/>

<

Formattertype

= "

xml

"/>

-

<

Batchtest Todir

= "

$ {junit.results}

">

<

Fileset

DIR

= "

$ {build.dir}

"

Includes

= "

** / * Test.class

"/>

Batchtest

>

Junit

>

Target

>

Configuration report

<

Publishers

>

<

CurrentBuildStatuspublisher

File

= "

CurrentBuild.txt

"/>

-

<

HTMLEMAIL Mailhost

= "

Mail.chelseafc.com.cn

"

ReturnAddress

= "

Workflow_engine@chelseafc.com.cn

"

SubjectPrefix

= "

ContinuousIntegration:

"

BuildResultsurl

= "

Http: // chelsea: 8044 / CruiseControl / BuildResults

"

Spamwhilebroken

= "

True

"

XSLDir

= "

F: /software/agile.net/cruiseControl-2.2/reporting/jsp/xsl

"

CSS

= "

F: /software/agile.net/cruiseControl-2.2/reporting/jsp/css/cruiseControl.css

"

logdir

= "

D: / Tomcat 4.1 / WebApps / CruiseControl / SampleLogs

">

<

Always

Address

= "

Chelsea@chelseafc.com.cn

"/>

<

Always

Address

= "

Ajax@chelseafc.com.cn

"/>

<

Map

Alias

= "

Chelsea

"

Address

= "

Chelsea@chelseafc.com.cn

"/>

HTMLEMAIL

>

Publishers

>

Where CruiseControl has no support for code inspection tools, it is recommended to use Ant to call Checkstyle, and examples are as follows (no truly run):

<

Target Name

= "

Web.checkstyle

">

<

Mkdir

DIR

= "

$ {target.temp} / checkstyle

"/>

<

Mkdir

DIR

= "

$ {target.web} / checkstyle

"/>

-

<

TaskDef resource

= "

Checkstylesetask.properties

">

-

<

Classpath

>

<

Fileset

DIR

= "

$ {support.tools} / checkstyle31

Includes

= "

** / *. jar

"/>

Classpath

>

Taskdef

>

-

<

Copy file

= "

$ {support.tools} /checkstyle31/custom.xml

"

Overwrite

= "

True

"

Tofile

= "

$ {target.temp} /checkstyle/custom.xml

">

-

<

Filterset

>

<

Filter

Token

= "

Source.java

"

Value

= "

$ {Basedir} / $ {source.java}

"/>

<

Filter

Token

= "

Target.checkstyle

"

Value

= "

$ {Basedir} / $ {target.temp} / checkstyle

"/>

Filterset

>

Copy

>

-

<

Checkstyle Config

= "

$ {target.temp} /checkstyle/custom.xml

"

Failonviolation

= "

False

">

<

Fileset

DIR

= "

$ {Source.java} / main

"

Includes

= "

** / *. Java

"/>

<

Formatter

Type

= "

Plain

"/>

<

Formatter

Type

= "

xml

"

Tofile

= "

$ {target.temp} /checkstyle/checkstyle_errors.xml

"/>

Checkstyle

>

<

Style

Basedir

= "

$ {target.temp} / checkstyle

"

Destdir

= "

$ {target.web} / checkstyle

"

Includes

= "

Checkstyle_errors.xml

"

Style

= "

$ {support.tools} /checkstyle31/checkstyle-noframes.xsl

"/>

Target

>

Five, some prompts

CruiseControl automatically controls remote VIEW monitoring remote VOB actually in addition to monitoring remote version control systems, CRUISECONTROL2.2 is only responsible for monitoring changes and calls Ant, CRUISECONTROL2.2, as if it cannot be in JDK5 .0 running, if you need to integrate JDK5.0, you need to specify Source and Target for the of Ant, and CruiseControl2.2 still starts with JDK1.4 can be added to CruiseControl.bat to start the startup parameter "-port 8055" This can control the CC to control the CC to avoid the Chinese path with JMX (http: // localhost: 8055). XML Version = "1.0" Encoding = "UTF-8"?> ", or the Chinese path mapping into a virtual hard disk:" Subst Y: "D: / cc_view / chelsea / platage / development / nucleus2.0/source" " When the Chinese log does not display properly, the "Encoding" property of the element in the CRUISEControl configuration file is required, such as: <

LOG DIR

= "

D: / Tomcat 4.1 / WebApps / CruiseControl / SampleLogs

"

ENCODING

= "

UTF-8

">

<

Merge

DIR

= "

D: /cc_view/chelseafc/nucleus2.0/port/test-results

"/>

log

>

After the compilation failed, before checkin, it is generally not re-compiled. At this time, the "buildAfterfailed" property that can set is false to avoid re-compiling the "HTMLEMail>" seem to have no default settings, although the document says From 2.1.7, there is default settings, including XSLDIR, CSS, LogDir installation, use, in their respective documents, and there are countless resources online.

Sixth, reference materials

DailyBuild Raiders Draco.net continues to integrate .NET manual

转载请注明原文地址:https://www.9cbs.com/read-81929.html

New Post(0)