How to auto build and deploy project

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值