您的位置:首页 > 产品设计 > UI/UE

How to auto build and deploy project

2008-03-06 10:09 573 查看
How to auto build and deploy project

1 Prepare software environment
1.1 copy “apache-ant-1.7.0” to your computer
For example: C:/apache-ant-1.7.0
It is used to run ant script
Copy “activation.jar” , “mail.jar” to C:/apache-ant-1.7.0/lib. It is used by the <mail> task.
Copy “activation.jar” to C:/apache-ant-1.7.0/lib. It is used by the <ftp> task.
You can see Library Dependencies for more information.
1.2 copy “cruisecontrol-bin-2.6.1” to your computer
For example: C:/cruisecontrol-bin-2.6.1
It is used to
1.3 copy “selenium-remote-control-0.9.0” to your computer
For example: C:/ selenium-remote-control-0.9.0
It is used to run selenium test

2 Set system environment variables
2.1 set Java environment variables
JAVA_HOME = D:/Program Files/IBM/JAVA50
-- that is your java installed directory(JDK1.4 or JDK1.5 is OK)
PATH = %JAVA_HOME%/bin;%PATH%
CLASSPATH = ./;%JAVA_HOME%/lib/tools.jar
2.2 set ant environment variables
ANT_HOME = D:/apache_ant_1.7.0
-- that is your ant installed directory
PATH = %ANT_HOME%/bin; %ANT_HOME%/lib

3 Write ant scripts
The ant scripts contain all the work that you want to do. Normally, there will be the following target to build and deploy a web application:
a) Build script
Initiate: make the directory needed.
Compile the source code.
Copy the files which are needed to the associated directories.
Replace some properties.
Run the junit tests if there are.
Build war package.
Build ear package.
b) Deploy script
Upload the ear package to the target computer by ftp. (If you want to deploy in the local computer, skip this)
Deploy by wsadmin.bat
c) Create database script
Use the <exec> task to run the db script.
d) BVT test script
Use the <junit> task to run the BVT test script
Now you can build and deploy by cmd. The command is “ant –f filename -l logname”. -f to designate filename and -l to designate logfilename.
Also you can write a bat file to run ant. This bat file will be run by cruisecontrol later. For example:
File name: ant_CQP.bat
File content: ant –f All_windows -l antlog_CQP.txt

4 Configure the cruise control
There is a configuration file for cruise control. Usually, it is named config.xml. You can see the Configuration Reference for more.
Here gives an example:
<cruisecontrol>

<property name="buildDir" value="C:/Build" />
<property name="ccbuildDir" value="C:/CruiseControlBuild" />
<property name="ccDir"
value="C:/cruisecontrol-bin-2.6.1/webapps/cruisecontrol" />

<project name="CQP" buildafterfailed="false" requireModification="false">

<property name="projectDir" value="M:/Daniel_CQP_Framework3.2_int"/>
<property name="buildscriptDir"
value="meritage_deployandbuild/BuildScript"/>
<property name="reportDir"
value="${buildDir}/${project.name}/test_report"/>
<property name="antlogDir" value="${ccbuildDir}"/>
<property name="antlog" value="antlog_${project.name}.txt"/>
<property name="antbat" value="ant_${project.name}.bat"/>

<listeners>
<currentbuildstatuslistener
file="${ccbuildDir}/logs/${project.name}/status.txt"
/>
</listeners>

<bootstrappers>
<clearcaseviewstrapper
viewpath="${projectDir}"
voblist="/meritage_framework"
/>
</bootstrappers>

<!-- schedule to build -->
<schedule interval="31104000">
<!-- run command which is given in the right place -->
<exec
command="${ccbuildDir}/${antbat}"
workingdir="${projectDir}/${buildscriptDir}"
/>
</schedule>

<!-- directory to write build logs to -->
<log dir="${ccbuildDir}/logs/${project.name}">
<merge dir="${reportDir}"/>
</log>

<!-- Publishers are run *after* a build completes -->
<publishers>
<!—copy build to target directory -->
<artifactspublisher
dest="${ccbuildDir}/artifacts/${project.name}"
dir="${buildDir}/${project.name}"
/>

<!—copy ant log to target directory -->
<artifactspublisher
dest="${ccbuildDir}/artifacts/${project.name}"
file="${ccbuildDir}/${antlog}"
/>

<!-- send email to notify that build finished -->
<htmlemail
buildresultsurl="http://9.181.106.125:8081/cruisecontrol/buildresults/${project.name}"
xsldir="${ccDir}/xsl"
css="${ccDir}/css/cruisecontrol.css"
mailhost="9.181.32.76"
returnaddress="zzheng@cn.ibm.com">
<always address="zzheng@cn.ibm.com"/>
<always address="wangdsh@cn.ibm.com"/>
</htmlemail>
</publishers>
</project>

</cruisecontrol>

5 Run
5.1 run selenium
Selenium needs Java50 to run. If your JRE are not version 1.5, please setup the jdk1.5, and run selenium like the following command.
"C:/Program Files/IBM/Java50/bin/java" -jar C:/selenium-remote-control-0.9.0/server/selenium-server.jar
If your JRE are version 1.5, then you can run selenium by the command bellowed.
java -jar C:/selenium-remote-control-0.9.0/server/selenium-server.jar
You can write a bat file to run selenium easily.
5.2 run cruisecontrol
Use the cmd to run cruisecontrol.
C:/cruisecontrol-bin-2.6.1/cruisecontrol.bat -configfile C:/CruiseControlBuild/config.xml -webport 8081
Use -configfile to designate configuration file, and use -webport to designate port.
Also, you can write a bat file to run selenium easily.

6 Build and deploy project
Open the web page: http://localhost:8081
Click the button build.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: