Development

Integrating a CVS Repository with IIB deployment using Ant Script

Before Integrating Ant Script with IIB deployment, please make sure the following steps have been covered:

Step 1:

set JAVA_HOME

Step 2:

go to below path and run mqsiprofile command if you have provided default path during installation Or go to the corresponding path and run the profile.

C:\Program Files\IBM\MQSI\7.0\bin\mqsiprofile.cmd

Step 3:

Configure the CVS.exe in your class path

step 4:

Configure build.xml in below path:

D:\ANT_HOME

Step 5:

execute Ant script as below from below path:

D:\ANT_HOME

ant -f build.xml

 

 

############################################################################################
#
#File Name: ant_Checkout.properties
#
#BarFiles – New Bars that needs to be checked out.
#DestinationDir – Where the checked out bar files needed to be placed.
#KId – Deluxe UserId Or KID (eg:k305681).
#Password – Deluxe Kid password.
#HostName – The server From which the Bars have to be checked out (eg:DEGPSA05).
#RepositoryPath – The path where all the bar files are located (eg:/opt/dfs/repository).
#Environment – the env from where the bar file should be checked out
#IT SHOULD BE ANY OF THE FOLLOWING 5 ENVIRONMENTS AND NAMES SHOULD BE GIVEN IN THE SAME WAY
#1_DEV,2_QA,3_UAT,4_Stage,5_XUAT,9_PROD
#target – Execution group from which the file need to be checkedout
#
#
############################################################################################

BarDestinationDir=D:/PRFT/Wrk_Folders/Neelakantan/DeploymentWorkSpace
commandbase=C:/Program Files/IBM/MQSI/7.0/bin
KId=k305681
Password=*******
HostName=DEGPSA05
CommitLogMessage=TEST
RepositoryPath=/opt/dfs/repository
Environment =2_QA
target=ESB_QA_EG3,ESB_QA_EG1
ESB_QA_EG3.bar=PlaceOrderService_MsgFlow.mf
ESB_QA_EG1.bar=AddressVelocity_MsgFlow.mf,PriceService.mf
systemip=10.111.17.83
port=1414
qmgr=DDGDAA20_D1
workspace=D:\PRFT\Wrk_Folders\Neelakantan

## Use the below properties to run the override alone for a given EG
##BarEGlist=AddressVelocity_MsgFlow.mf,PriceService.mf
##EG=ESB_QA_EG1

 

####################################################################

 

<!– Ant Script for Integrating CVS checkout checkin with Bar Override and Deployment –>

<?xml version=”1.0″?>

<!– Providing project name and calling the first target InitilizeCheckoutProcess –>
<project name=”CVS Checkout” default=”InitilizeCheckoutProcess” basedir=”.”>
<taskdef resource=”net/sf/antcontrib/antcontrib.properties”>
</taskdef>

<taskdef resource=”net/sf/antcontrib/antlib.xml”>
</taskdef>
<!– In this target we are initializing the Property file ant_Checkout.properties–>
<target name=”InitilizeCheckoutProcess”>
<property file=”ant_Checkout.properties”/>
<echo message=”checking out these bar files :- ${BarFiles}”/>
<echo message=””/>
<!– Getting all the target Execution group one by one from property file –>
<foreach list=”${target}” delimiter=”,” param=”EG” target=”CallCheckout” inheritall=”true”/>
</target>

<target name=”CallCheckout”>
<!– With property copy we are copying the value from the target EG one by one–>
<propertycopy name=”BarEGlist” from=”${EG}.bar” silent=”true”/>
<echo message = “userid is : – ${KId}”/>
<echo message = “Eg Name :- ${EG} “/>
<foreach list=”${BarEGlist}” delimiter=”,” param=”msgflow” target=”ConnectAndCheckout” inheritall=”true”/>
</target>
<!– Using CVS commands we connect to CVS repository and Checkout the packages–>
<target name=”ConnectAndCheckout”>
<!– Please note that cvsroot values are taken from Property file–>
<!– package is the bar or application that needs to be checked out–>
<!– Destination is where the checked out contents need to be placed–>
<cvs cvsroot=”:pserver:${KId}:${Password}@${HostName}:${RepositoryPath}” package=”waamq/SOASupport/${Environment}/BarFiles/${EG}/${msgflow}.bar” dest=”${BarDestinationDir}”/>
<cvs cvsroot=”:pserver:${KId}:${Password}@${HostName}:${RepositoryPath}” package = “waamq/SOASupport/${Environment}/ConfigFiles/${EG}/${msgflow}.cfg” dest=”${BarDestinationDir}” />
<antcall target=”applybaroverride”/>
</target>
<!– Overriding the Property file with the latest bar file–>
<target name =”applybaroverride”>
<!– Checking wether we have property file for a bar file–>
<if>
<available file=”${BarDestinationDir}/waamq/SOASupport/${Environment}/ConfigFiles/${EG}/${msgflow}.cfg”/>
<then>
<echo message=”Start overriding broker archive file :- ${msgflow}.bar”/>
<exec executable=”mqsiapplybaroverride.exe” failonerror=”true” logError=”true” spawn=”false”>
<arg value=”-b”/>
<arg value=”${BarDestinationDir}/waamq/SOASupport/${Environment}/BarFiles/${EG}/${msgflow}.bar”/>
<arg value=”-p”/>
<arg value=”${BarDestinationDir}/waamq/SOASupport/${Environment}/ConfigFiles/${EG}/${msgflow}.cfg”/>
</exec>
<echo message=”Completed overriding broker archive file :- ${msgflow}.bar”/>
<echo message=””/>
<!– To Copy bar files to the workspace of the deployment server dependent on the environment –>
<copy todir=”${BarDestinationDir}”>
<fileset dir=”${BarDestinationDir}/waamq/SOASupport/${Environment}/BarFiles/${EG}”>
<include name=”*.bar”/>
</fileset>
</copy>

</then>

<else>
<echo message=”${msgflow}.cfg not found. Skipping bar Override on ${msgflow}.bar” />
<echo message=””/>
</else>
</if>
<antcall target=”deploybar”/>
</target>

<target name=”stopflow”>
<echo message=”Stopping ${msgflow} / ${EG} / ${qmgr} …”/>
<!– Checking to see if the bar is Message flow if so We need to stop the flow before deleting–>
<if>
<contains string=”${msgflow}” substring=”.ms” />
<then>
<echo message=”Message set ${msgflow} to be deployed. Skipping the mqsistopmsgflow…”/>
</then>
<else>
<propertyregex property=”stopflow”
input=”${msgflow}”
regexp=”.*”
replace=””
global=”true”
defaultValue=”${msgflow}”/>

<exec executable=”${commandbase}/mqsistopmsgflow.bat” failonerror=”true” logError=”true” vmlauncher=”false” append=”true” spawn=”false”>
<arg value=”-i”/>
<arg value=”${systemip}”/>
<arg value=”-p”/>
<arg value=”${port}”/>
<arg value=”-q”/>
<arg value=”${qmgr}”/>
<arg value=”-e”/>
<arg value=”${EG}”/>
<arg value=”-m”/>
<arg value=”${stopflow}”/>
</exec>
<echo message=”Stopped the message flow ${msgflow} / ${EG} / ${qmgr} successfully…”/>
</else>
</if>
</target>
<!– Deleting the Previously deployed content in this case Message flow or Message set for clean deployment–>
<target name=”deleteflow” depends=”stopflow”>

<echo message=”Deleting the message flow ${msgflow} / ${EG} / ${qmgr} …”/>
<propertyregex property=”stopflow”
input=”${msgflow}”
regexp=”.*”
replace=””
global=”true”
defaultValue=”${msgflow}”/>

<exec executable=”${commandbase}/mqsideployscript.bat” failonerror=”true” logError=”true” vmlauncher=”false” append=”true” spawn=”false”>
<arg value=”-i”/>
<arg value=”${systemip}”/>
<arg value=”-p”/>
<arg value=”${port}”/>
<arg value=”-q”/>
<arg value=”${qmgr}”/>
<arg value=”-e”/>
<arg value=”${EG}”/>
<arg value=”-d”/>
<arg value=”${stopflow}”/>
</exec>
<echo message=”Deleted the message flow ${msgflow} / ${EG} / ${qmgr} successfully…”/>
</target>
<!–Deploying the bar file–>
<target name=”deploybar” depends=”deleteflow”>

<echo message=”Deploying the message flow ${msgflow} / ${EG} / ${qmgr}…”/>

<exec executable=”${commandbase}/mqsideployscript.bat” failonerror=”true” logError=”true” vmlauncher=”false” append=”true” spawn=”false”>
<arg value=”-i”/>
<arg value=”${systemip}”/>
<arg value=”-p”/>
<arg value=”${port}”/>
<arg value=”-q”/>
<arg value=”${qmgr}”/>
<arg value=”-e”/>
<arg value=”${EG}”/>
<arg value=”-a”/>
<arg value=”${BarDestinationDir}/${msgflow}.bar”/>
</exec>
<echo message=”Deployed the message flow ${msgflow} / ${EG} / ${qmgr} successfully…”/>
</target>
<!–Commiting the changes back to the repository and checking in the code –>
<target name=”Commitandcheckin” depends=”deploybar”>
<cvs cvsroot=”:pserver:${KId}:${Password}@${HostName}:${RepositoryPath}” command=”-q commit -m ${CommitLogMessage} -f ${BarDestinationDir}/waamq/SOASupport/${Environment}/BarFiles/${EG}/${msgflow}.bar”/>
</target>
</project>

 

 

 

About the Author

More from this Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up
Categories