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.
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.
相关文章推荐
- Pragmatic Project Automation: How to Build, Deploy, and Monitor Java Apps
- SQL Server 2008 – How To Build and Deploy AdventureWorks OLAP Cubes
- How to build & install GLFW 3 and use it in a Linux project
- how to build your web application on spring boot and deploy it on heroku
- use MSBuild cmd to build and deploy the database project.
- how to build your web application on spring boot and deploy it on heroku
- MS Project Tutorials - How to build a project plan
- How to deploy maven project to tomcat inside your eclipse
- How-to-design-and-deploy-a-new-master-page-for-sharepoint-2010
- How to build samba PDC and add client
- How to build a COM to Send and Receive Multi File by ATL
- How To Build xfstools, xfsprogs And xfsdump From Source On Ubuntu
- How to remove group and project in Gerrit
- Unity: How to build and debug external DLLs
- How to Build An Action and Emotion Database for Simulated Driver’s State Recognition
- How to create a Maven web app and deploy to Tomcat - fast
- How to configure a C/C++ project with Eclipse and CMake
- 【转载】How to build and run your first deep learning network
- How to build and install Open vSwitch on a linux
- How to build monitoring system with Face Recognization by HTC Hero、VideoLAN and EmguCV.