How to auto build and deploy project
<o:p></o:p>
1 Prepare software environment<o:p></o:p>
1.1 copy “apache-ant-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">1.7.0</st1:chsdate>” to your computer<o:p></o:p>
For example: C:\apache-ant-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">1.7.0</st1:chsdate><o:p></o:p>
It is used to run ant script<o:p></o:p>
Copy “activation.jar” , “mail.jar” to C:\apache-ant-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">1.7.0</st1:chsdate>\lib. It is used by the <mail> task. <o:p></o:p>
Copy “activation.jar” to C:\apache-ant-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">1.7.0</st1:chsdate>\lib. It is used by the <ftp> task. <o:p></o:p>
You can see Library Dependencies for more information.<o:p></o:p>
1.2 copy “cruisecontrol-bin-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">2.6.1</st1:chsdate>” to your computer<o:p></o:p>
For example: C:\cruisecontrol-bin-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">2.6.1</st1:chsdate><o:p></o:p>
It is used to <o:p></o:p>
1.3 copy “selenium-remote-control-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">0.9.0</st1:chsdate>” to your computer<o:p></o:p>
For example: C:\ selenium-remote-control-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">0.9.0</st1:chsdate><o:p></o:p>
It is used to run selenium test<o:p></o:p>
<o:p> </o:p>
2 Set system environment variables <o:p></o:p>
2.1 set Java environment variables<o:p></o:p>
JAVA_HOME = D:\Program Files\IBM\JAVA50<o:p></o:p>
-- that is your java installed directory(JDK1.4 or JDK1.5 is OK)<o:p></o:p>
PATH = %JAVA_HOME%\bin;%PATH%<o:p></o:p>
CLASSPATH = .\;%JAVA_HOME%\lib\tools.jar<o:p></o:p>
2.2 set ant environment variables<o:p></o:p>
ANT_HOME = D:\apache_ant_<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">1.7.0</st1:chsdate><o:p></o:p>
-- that is your ant installed directory<o:p></o:p>
PATH = %ANT_HOME%\bin; %ANT_HOME%\lib<o:p></o:p>
<o:p> </o:p>
3 Write ant scripts<o:p></o:p>
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: <o:p></o:p>
a) Build script<o:p></o:p>
Initiate: make the directory needed.<o:p></o:p>
Compile the source code.<o:p></o:p>
Copy the files which are needed to the associated directories.<o:p></o:p>
Replace some properties.<o:p></o:p>
Run the junit tests if there are.<o:p></o:p>
Build war package.<o:p></o:p>
Build ear package.<o:p></o:p>
b) Deploy script<o:p></o:p>
Upload the ear package to the target computer by ftp. (If you want to deploy in the local computer, skip this)<o:p></o:p>
Deploy by wsadmin.bat<o:p></o:p>
c) Create database script<o:p></o:p>
Use the <exec> task to run the db script.<o:p></o:p>
d) BVT test script<o:p></o:p>
Use the <junit> task to run the BVT test script<o:p></o:p>
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.<o:p></o:p>
Also you can write a bat file to run ant. This bat file will be run by cruisecontrol later. For example: <o:p></o:p>
File name: ant_CQP.bat<o:p></o:p>
File content: ant –f All_windows -l antlog_CQP.txt <o:p></o:p>
<o:p> </o:p>
4 Configure the cruise control<o:p></o:p>
There is a configuration file for cruise control. Usually, it is named config.xml. You can see the Configuration Reference for more.<o:p></o:p>
Here gives an example:<o:p></o:p>
<cruisecontrol><o:p></o:p>
<o:p> </o:p>
<property name="buildDir" value="C:\Build" /><o:p></o:p>
<property name="ccbuildDir" value="C:\CruiseControlBuild" /><o:p></o:p>
<property name="ccDir" <o:p></o:p>
value="C:\cruisecontrol-bin-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">2.6.1</st1:chsdate>\webapps\cruisecontrol" /><o:p></o:p>
<o:p></o:p>
<project name="CQP" buildafterfailed="false" requireModification="false"><o:p></o:p>
<o:p></o:p>
<property name="projectDir" value="M:\Daniel_CQP_Framework3.2_int"/><o:p></o:p>
<property name="buildscriptDir" <o:p></o:p>
value="meritage_deployandbuild\BuildScript"/><o:p></o:p>
<property name="reportDir" <o:p></o:p>
value="${buildDir}\${project.name}\test_report"/><o:p></o:p>
<property name="antlogDir" value="${ccbuildDir}"/><o:p></o:p>
<property name="antlog" value="antlog_${project.name}.txt"/><o:p></o:p>
<property name="antbat" value="ant_${project.name}.bat"/><o:p></o:p>
<o:p> </o:p>
<listeners><o:p></o:p>
<currentbuildstatuslistener <o:p></o:p>
file="${ccbuildDir}/logs/${project.name}/status.txt"<o:p></o:p>
/><o:p></o:p>
</listeners><o:p></o:p>
<o:p> </o:p>
<bootstrappers><o:p></o:p>
<clearcaseviewstrapper <o:p></o:p>
viewpath="${projectDir}" <o:p></o:p>
voblist="\meritage_framework"<o:p></o:p>
/><o:p></o:p>
</bootstrappers><o:p></o:p>
<o:p> </o:p>
<!-- schedule to build --><o:p></o:p>
<schedule interval="31104000"><o:p></o:p>
<!-- run command which is given in the right place --><o:p></o:p>
<exec <o:p></o:p>
command="${ccbuildDir}\${antbat}"<o:p></o:p>
workingdir="${projectDir}\${buildscriptDir}"<o:p></o:p>
/><o:p></o:p>
</schedule><o:p></o:p>
<o:p> </o:p>
<!-- directory to write build logs to --><o:p></o:p>
<log dir="${ccbuildDir}/logs/${project.name}"><o:p></o:p>
<merge dir="${reportDir}"/><o:p></o:p>
</log><o:p></o:p>
<o:p> </o:p>
<!-- Publishers are run *after* a build completes --><o:p></o:p>
<publishers><o:p></o:p>
<!—copy build to target directory --><o:p></o:p>
<artifactspublisher <o:p></o:p>
dest="${ccbuildDir}\artifacts\${project.name}"<o:p></o:p>
dir="${buildDir}\${project.name}"<o:p></o:p>
/><o:p></o:p>
<o:p></o:p>
<!—copy ant log to target directory --><o:p></o:p>
<artifactspublisher <o:p></o:p>
dest="${ccbuildDir}\artifacts\${project.name}"<o:p></o:p>
file="${ccbuildDir}\${antlog}"<o:p></o:p>
/><o:p></o:p>
<o:p></o:p>
<!-- send email to notify that build finished --><o:p></o:p>
<htmlemail<o:p></o:p>
buildresultsurl="http://9.181.106.125:8081/cruisecontrol/buildresults/${project.name}"<o:p></o:p>
xsldir="${ccDir}\xsl"<o:p></o:p>
css="${ccDir}\css\cruisecontrol.css"<o:p></o:p>
mailhost="9.181.32.76"<o:p></o:p>
returnaddress="zzheng@cn.ibm.com"><o:p></o:p>
<always address="zzheng@cn.ibm.com"/><o:p></o:p>
<always address="wangdsh@cn.ibm.com"/><o:p></o:p>
</htmlemail><o:p></o:p>
</publishers><o:p></o:p>
</project><o:p></o:p>
<o:p> </o:p>
</cruisecontrol><o:p></o:p>
<o:p> </o:p>
5 Run<o:p></o:p>
5.1 run selenium<o:p></o:p>
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.<o:p></o:p>
"C:/Program Files/IBM/Java50/bin/java" -jar C:/selenium-remote-control-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">0.9.0</st1:chsdate>/server/selenium-server.jar<o:p></o:p>
If your JRE are version 1.5, then you can run selenium by the command bellowed.<o:p></o:p>
java -jar C:/selenium-remote-control-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">0.9.0</st1:chsdate>/server/selenium-server.jar<o:p></o:p>
You can write a bat file to run selenium easily.<o:p></o:p>
5.2 run cruisecontrol<o:p></o:p>
Use the cmd to run cruisecontrol. <o:p></o:p>
C:\cruisecontrol-bin-<st1:chsdate isrocdate="False" month="12" islunardate="False" day="30" w:st="on" year="1899">2.6.1</st1:chsdate>\cruisecontrol.bat -configfile C:\CruiseControlBuild\config.xml -webport 8081<o:p></o:p>
Use -configfile to designate configuration file, and use -webport to designate port.<o:p></o:p>
Also, you can write a bat file to run selenium easily.<o:p></o:p>
<o:p> </o:p>
6 Build and deploy project<o:p></o:p>
Open the web page: http://localhost:8081<o:p></o:p>
Click the button build.<o:p></o:p>