Steps to setup and deploy SOA code to server using ANT.
Script Scope:
a. Deploys code to soa server [standalone/cluster]
b. Can be used for both 11g and 12c version of code.
c. Uses soa-config plan for deployment [please comment related code snippet if plan not required].
d. Creates a log file on date basis for basic logging.
Prerequisites:
a. Create folder ANT.
b. Inside create folders; config, lib, deploy, logs.
Steps:
1. Create file soa-build.properties like below [update paths as per your machine]
#Global
wls.bea.home=E:/Oracle/Middleware/Oracle_Home
wl_home=${wls.bea.home}/wlserver
oracle.home=${wls.bea.home}/jdeveloper
java.passed.home=C:/Program Files/Java/jdk1.8.0_131
#Temp
tmp.output.dir=deploy
#Delete the temp folder after the build
DeleteTemp=true
#Composite Setting
composite.enable=true
2. Create file soa-environment.properties like below [update values as per your server]
#Deployment server weblogic
dev.user=weblogic
dev.password=welcome1
dev.serverURL=http://localhost:7004
dev.server=localhost\
dev.port=7004
dev.overwrite=true
dev.forceDefault=true
3. Create file soa-project.properties like below [update values as per your requirement]
HelloWorldSOAApp.projects=HelloWorldProject1, HelloWorldProject2
HelloWorldSOAApp.src=E:/Code/HelloWorld
HelloWorldSOAApp.partition=default
HelloWorldProject1.version=1.0
HelloWorldProject1.deploy=true
HelloWorldProject2.version=1.0
HelloWorldProject2.deploy=true
4. Place all 3 property files inside config folder.
5. Copy your .adf folder from your project META-INF folder and paste inside config folder
Edit your adf-config.xml file. You can do either of 2 things:
a. Add a connection using DB-based MDS
b. Edit the File-based MDS variable to physical path where you MDS is located for apps and seed
6. Download ant-contrib-1.0b3.jar and place inside lib folder.
7. Create file build.xml like below
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="help">
<!--Global Default Task-->
<echo>basedir ${basedir}</echo>
<property name="application" value="${appName}"/>
<!-- Antcontrib path -->
<path id="antcontrib.path">
<pathelement path="lib/ant-contrib-1.0b3.jar" />
</path>
<taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antcontrib.properties"/>
<taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antlib.xml"/>
<!-- help -->
<target name="help">
<echo>
##########################CreatedByNadimWarsi#######################
------------------------------------------------------
| Usable targets are: |
------------------------------------------------------
help - This help
deployAll - Packages and deploys all applications and their listed projects
deployApp - Packages and deploys one application and its listed projects
deployAppProject - Packages and deploys one project
------------------------------------------------------
| Usage example: |
------------------------------------------------------
echo $ANT_HOME
echo $JAVA_HOME
export ANT_HOME=/apps/FMW/oracle_common/modules/org.apache.ant_1.9.2
export JAVA_HOME=/apps/java/jdk/jdk1.8.0_131
ant -f help -Dtargetenv=dev
ant -f deployAll -Dtargetenv=dev
ant -f deployApp -Dtargetenv=dev -DappName=HelloWorldSOAApp
ant -f deployAppProject -Dtargetenv=dev -DappName=HelloWorldSOAApp -Dprojects=HelloWorld1
############################################################
</echo>
</target>
<!-- Check for an load property files -->
<fail message="ERROR: Parameter 'targetenv' missing.">
<condition>
<not>
<isset property="targetenv" />
</not>
</condition>
</fail>
<available file="config/soa-build.properties" property="file.exists" value="true" />
<fail unless="file.exists" message="ERROR: Filename 'config/soa-build.properties' does not exist." />
<property file="config/soa-build.properties"/>
<available file="config/soa-project.properties" property="file.exists" value="true" />
<fail unless="file.exists" message="ERROR: Filename 'config/soa-project.properties' does not exist." />
<property file="config/soa-project.properties"/>
<available file="config/soa-environment.properties" property="file.exists" value="true" />
<fail unless="file.exists" message="ERROR: Filename 'config/soa-environment.properties' does not exist." />
<property file="config/soa-environment.properties"/>
<tstamp>
<format property="log.date" pattern="ddMMyyy"/>
<format property="log.time" pattern="dd-MM-yyy HH:mm:ss"/>
</tstamp>
<echo file="logs/instance-${log.date}.log" append="true" message="${line.separator}${log.time}${line.separator}" level="info"/>
<!-- Target Deployment -->
<target name="deployAll">
<echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployAll -Dtargetenv=${targetenv}${line.separator}" level="info"/>
<antcall target="build.HelloWorldSOAApp"/>
<echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
</target>
<!--Individual Targets for each SOA application-->
<target name="build.HelloWorldSOAApp">
<antcall target="deployAppProject">
<param name="application" value="HelloWorldSOAApp"/>
<param name="projects" value="${HelloWorldSOAApp.projects}"/>
</antcall>
</target>
<!--Application Deployment-->
<target name="deployApp">
<echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployApp -Dtargetenv=${targetenv} -DappName=${application}${line.separator}" level="info"/>
<propertycopy name="projects" from="${application}.projects"/>
<antcall target="deployAppProject">
<param name="application" value="${application}"/>
<param name="projects" value="${projects}"/>
</antcall>
<echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
</target>
<!--Application Project Deployment-->
<target name="deployAppProject">
<echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployAppProject -Dtargetenv=${targetenv} -DappName=${application} -Dprojects=${projects}${line.separator}" level="info"/>
<echo>Deploy application ${application}</echo>
<echo>Project(s): ${projects}</echo>
<foreach list="${projects}" param="project" target="deployProject" inheritall="true" inheritrefs="false"/>
<echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
</target>
<!--Project Deployment-->
<target name="deployProject">
<trycatch property="tryName" reference="exception_ref">
<try>
<property name="proj.compositeName" value="${project}"/>
<propertycopy name="proj.deploy" from="${proj.compositeName}.deploy"/>
<if>
<matches pattern="true|True|TRUE" string="${proj.deploy}"/>
<then>
<echo>Deploying ${project}</echo>
<tstamp>
<format property="current.time" pattern="yyyyMMdd_HHmmss"/>
<format property="build.date" pattern="dd-MM-yyyy"/>
</tstamp>
<propertycopy name="src" from="${application}.src"/>
<echo>Copying application folder '${src}/${application}' to temp folder '${tmp.output.dir}/${application}/${current.time}'</echo>
<copy todir="${tmp.output.dir}/${application}/${current.time}">
<fileset dir="${src}/${application}"></fileset>
</copy>
<property name="proj.compositeDir" value="${tmp.output.dir}/${application}/${current.time}"/>
<propertycopy name="proj.revision" from="${proj.compositeName}.version"/>
<property name="proj.enabled" value="${enabled}"/>
<echo>Deploying compositeDir: ${proj.compositeDir}</echo>
<echo>Deploying compositeName: ${proj.compositeName}</echo>
<echo>Deploying version: ${proj.revision}</echo>
<echo>Environment: ${targetenv}</echo>
<echo>Build Date: ${build.date}</echo>
<!--Checking if 11g or 12c code structure-->
<if>
<available file="${proj.compositeDir}/${proj.compositeName}/SOA" type="dir"/>
<then>
<property name="project.soa.dir" value="${proj.compositeDir}/${proj.compositeName}/SOA"/>
</then>
<else>
<property name="project.soa.dir" value="${proj.compositeDir}/${proj.compositeName}"/>
</else>
</if>
<!--Loading common .adf config file for targetenv MDS in META-INF-->
<property name="adfdir" value="${basedir}/config"/>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-package.xml" inheritAll="false" target="package">
<property name="compositeDir" value="${basedir}/${project.soa.dir}"/>
<property name="compositeName" value="${proj.compositeName}"/>
<property name="revision" value="${proj.revision}"/>
<property name="oracle.home" value="${oracle.home}"/>
<property name="java.passed.home" value="${java.passed.home}"/>
<property name="wl_home" value="${wl_home}"/>
<property name="sca.application.home" value="${basedir}/${proj.compositeDir}"/>
<property name="scac.application.home" value="${adfdir}"/>
<property name="scac.input" value="${project.soa.dir}/composite.xml"/>
<property name="scac.output" value="${tmp.output.dir}/${proj.compositeName}.xml"/>
<property name="scac.error" value="${tmp.output.dir}/${proj.compositeName}.err"/>
<property name="scac.displayLevel" value="3"/>
</ant>
<path id="cfgpln-file">
<fileset dir="${project.soa.dir}">
<include name="${proj.compositeName}_cfgplan_${targetenv}.xml"/>
</fileset>
</path>
<property name="deploy.configplan" refid="cfgpln-file"/>
<property name="deploy.sarLocation" value="${project.soa.dir}/deploy/sca_${proj.compositeName}_rev${proj.revision}.jar"/>
<property name="deploy.sarLocation" value="${project.soa.dir}/deploy/sca_${proj.compositeName}_rev${proj.revision}.jar"/>
<propertycopy name="deploy.overwrite" from="${targetenv}.overwrite"/>
<propertycopy name="deploy.user" from="${targetenv}.user"/>
<propertycopy name="deploy.password" from="${targetenv}.password"/>
<propertycopy name="deploy.forceDefault" from="${targetenv}.forceDefault"/>
<propertycopy name="deploy.server" from="${targetenv}.server"/>
<propertycopy name="deploy.port" from="${targetenv}.port"/>
<propertycopy name="deploy.serverURL" from="${targetenv}.serverURL"/>
<propertycopy name="deploy.partition" from="${application}.partition"/>
<echo>Deploying to ${deploy.serverURL} with user ${deploy.user}</echo>
<echo>sarFile: ${deploy.sarLocation}</echo>
<echo>Deploying with configPlan is ${deploy.configplan}</echo>
<echo>Server: ${deploy.server}</echo>
<echo>Port: ${deploy.port}</echo>
<echo>Partition/Folder: ${deploy.partition}</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="CompositeName: ${proj.compositeName}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Revision: ${proj.revision}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Partition: ${deploy.partition}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Deploy to ${deploy.serverURL} with user ${deploy.user}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Overwrite: ${deploy.overwrite}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="forceDefault: ${deploy.forceDefault}${line.separator}" level="info"/>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-deploy.xml" inheritAll="false" target="deploy">
<property name="wl_home" value="${wl_home}"/>
<property name="oracle.home" value="${oracle.home}"/>
<property name="serverURL" value="${deploy.serverURL}"/>
<property name="user" value="${deploy.user}"/>
<property name="password" value="${deploy.password}"/>
<property name="overwrite" value="${deploy.overwrite}"/>
<property name="forceDefault" value="${deploy.forceDefault}"/>
<property name="sarLocation" value="${deploy.sarLocation}"/>
<property name="partition" value="${deploy.partition}"/>
<property name="configplan" value="${deploy.configplan}"/>
</ant>
<echo>Disable or Enable composite set to: ${composite.enable}</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="Composite enabled: ${composite.enable}${line.separator}" level="info"/>
<if>
<equals arg1="${composite.enabled}" arg2="false"/>
<then>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-mgmt.xml" inheritAll="false" target="stopComposite">
<property name="host" value="${deploy.server}"/>
<property name="port" value="${deploy.port}"/>
<property name="user" value="${deploy.user}"/>
<property name="password" value="${deploy.password}"/>
<property name="compositeName" value="${proj.compositeName}"/>
<property name="revision" value="${proj.revision}"/>
</ant>
</then>
</if>
<if>
<equals arg1="${composite.enabled}" arg2="true"/>
<then>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-mgmt.xml" inheritAll="false" target="activateComposite">
<property name="host" value="${deploy.server}"/>
<property name="port" value="${deploy.port}"/>
<property name="user" value="${deploy.user}"/>
<property name="password" value="${deploy.password}"/>
<property name="compositeName" value="${proj.compositeName}"/>
<property name="revision" value="${proj.revision}"/>
</ant>
<echo>Unit Test project ${proj.compositeName}</echo>
</then>
</if>
<echo>${proj.compositeName}${proj.revision} deployment is complete.</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="Command Execution Status: SUCCESSFUL${line.separator}${line.separator}" level="info"/>
<if>
<matches pattern="true" string="${DeleteTemp}"/>
<then>
<echo>Cleaning temp folder: ./${tmp.output.dir}</echo>
<delete includeemptydirs="true">
<fileset dir="${tmp.output.dir}" includes="**/*"/>
</delete>
</then>
</if>
</then>
<else>
<echo>${proj.compositeName} deployment is skipping, check the property ${proj.compositeName}.deploy is set to false.</echo>
</else>
</if>
</try>
<catch>
<property name="exception" refid="exception_ref" />
<property name="message" value="ERROR IN TRYCATCH BLOCK:${exception}" />
<echo></echo>
<echo>${message}</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="Command Execution Status: FAILED${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Error message: ${message}${line.separator}${line.separator}" level="info"/>
</catch>
</trycatch>
</target>
</project>
8. Save All.
9. Open cmd/putty, and set ANT_HOME.
10. Execute command like ant -f deployAll -Dtargetenv=dev
Note:
a. Verify your path for all the ant sca xmls are correct.
b. Verify your adf-config.xml is correct.
Helpful? Please Comment.
Happy Learning!!
Script Scope:
a. Deploys code to soa server [standalone/cluster]
b. Can be used for both 11g and 12c version of code.
c. Uses soa-config plan for deployment [please comment related code snippet if plan not required].
d. Creates a log file on date basis for basic logging.
Prerequisites:
a. Create folder ANT.
b. Inside create folders; config, lib, deploy, logs.
Steps:
1. Create file soa-build.properties like below [update paths as per your machine]
#Global
wls.bea.home=E:/Oracle/Middleware/Oracle_Home
wl_home=${wls.bea.home}/wlserver
oracle.home=${wls.bea.home}/jdeveloper
java.passed.home=C:/Program Files/Java/jdk1.8.0_131
#Temp
tmp.output.dir=deploy
#Delete the temp folder after the build
DeleteTemp=true
#Composite Setting
composite.enable=true
2. Create file soa-environment.properties like below [update values as per your server]
#Deployment server weblogic
dev.user=weblogic
dev.password=welcome1
dev.serverURL=http://localhost:7004
dev.server=localhost\
dev.port=7004
dev.overwrite=true
dev.forceDefault=true
3. Create file soa-project.properties like below [update values as per your requirement]
HelloWorldSOAApp.projects=HelloWorldProject1, HelloWorldProject2
HelloWorldSOAApp.src=E:/Code/HelloWorld
HelloWorldSOAApp.partition=default
HelloWorldProject1.version=1.0
HelloWorldProject1.deploy=true
HelloWorldProject2.version=1.0
HelloWorldProject2.deploy=true
4. Place all 3 property files inside config folder.
5. Copy your .adf folder from your project META-INF folder and paste inside config folder
Edit your adf-config.xml file. You can do either of 2 things:
a. Add a connection using DB-based MDS
b. Edit the File-based MDS variable to physical path where you MDS is located for apps and seed
6. Download ant-contrib-1.0b3.jar and place inside lib folder.
7. Create file build.xml like below
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="help">
<!--Global Default Task-->
<echo>basedir ${basedir}</echo>
<property name="application" value="${appName}"/>
<!-- Antcontrib path -->
<path id="antcontrib.path">
<pathelement path="lib/ant-contrib-1.0b3.jar" />
</path>
<taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antcontrib.properties"/>
<taskdef classpathref="antcontrib.path" resource="net/sf/antcontrib/antlib.xml"/>
<!-- help -->
<target name="help">
<echo>
##########################CreatedByNadimWarsi#######################
------------------------------------------------------
| Usable targets are: |
------------------------------------------------------
help - This help
deployAll - Packages and deploys all applications and their listed projects
deployApp - Packages and deploys one application and its listed projects
deployAppProject - Packages and deploys one project
------------------------------------------------------
| Usage example: |
------------------------------------------------------
echo $ANT_HOME
echo $JAVA_HOME
export ANT_HOME=/apps/FMW/oracle_common/modules/org.apache.ant_1.9.2
export JAVA_HOME=/apps/java/jdk/jdk1.8.0_131
ant -f help -Dtargetenv=dev
ant -f deployAll -Dtargetenv=dev
ant -f deployApp -Dtargetenv=dev -DappName=HelloWorldSOAApp
ant -f deployAppProject -Dtargetenv=dev -DappName=HelloWorldSOAApp -Dprojects=HelloWorld1
############################################################
</echo>
</target>
<!-- Check for an load property files -->
<fail message="ERROR: Parameter 'targetenv' missing.">
<condition>
<not>
<isset property="targetenv" />
</not>
</condition>
</fail>
<available file="config/soa-build.properties" property="file.exists" value="true" />
<fail unless="file.exists" message="ERROR: Filename 'config/soa-build.properties' does not exist." />
<property file="config/soa-build.properties"/>
<available file="config/soa-project.properties" property="file.exists" value="true" />
<fail unless="file.exists" message="ERROR: Filename 'config/soa-project.properties' does not exist." />
<property file="config/soa-project.properties"/>
<available file="config/soa-environment.properties" property="file.exists" value="true" />
<fail unless="file.exists" message="ERROR: Filename 'config/soa-environment.properties' does not exist." />
<property file="config/soa-environment.properties"/>
<tstamp>
<format property="log.date" pattern="ddMMyyy"/>
<format property="log.time" pattern="dd-MM-yyy HH:mm:ss"/>
</tstamp>
<echo file="logs/instance-${log.date}.log" append="true" message="${line.separator}${log.time}${line.separator}" level="info"/>
<!-- Target Deployment -->
<target name="deployAll">
<echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployAll -Dtargetenv=${targetenv}${line.separator}" level="info"/>
<antcall target="build.HelloWorldSOAApp"/>
<echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
</target>
<!--Individual Targets for each SOA application-->
<target name="build.HelloWorldSOAApp">
<antcall target="deployAppProject">
<param name="application" value="HelloWorldSOAApp"/>
<param name="projects" value="${HelloWorldSOAApp.projects}"/>
</antcall>
</target>
<!--Application Deployment-->
<target name="deployApp">
<echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployApp -Dtargetenv=${targetenv} -DappName=${application}${line.separator}" level="info"/>
<propertycopy name="projects" from="${application}.projects"/>
<antcall target="deployAppProject">
<param name="application" value="${application}"/>
<param name="projects" value="${projects}"/>
</antcall>
<echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
</target>
<!--Application Project Deployment-->
<target name="deployAppProject">
<echo file="logs/instance-${log.date}.log" append="true" message="Command: ant -f deployAppProject -Dtargetenv=${targetenv} -DappName=${application} -Dprojects=${projects}${line.separator}" level="info"/>
<echo>Deploy application ${application}</echo>
<echo>Project(s): ${projects}</echo>
<foreach list="${projects}" param="project" target="deployProject" inheritall="true" inheritrefs="false"/>
<echo file="logs/instance-${log.date}.log" append="true" message="##########################################################${line.separator}" level="info"/>
</target>
<!--Project Deployment-->
<target name="deployProject">
<trycatch property="tryName" reference="exception_ref">
<try>
<property name="proj.compositeName" value="${project}"/>
<propertycopy name="proj.deploy" from="${proj.compositeName}.deploy"/>
<if>
<matches pattern="true|True|TRUE" string="${proj.deploy}"/>
<then>
<echo>Deploying ${project}</echo>
<tstamp>
<format property="current.time" pattern="yyyyMMdd_HHmmss"/>
<format property="build.date" pattern="dd-MM-yyyy"/>
</tstamp>
<propertycopy name="src" from="${application}.src"/>
<echo>Copying application folder '${src}/${application}' to temp folder '${tmp.output.dir}/${application}/${current.time}'</echo>
<copy todir="${tmp.output.dir}/${application}/${current.time}">
<fileset dir="${src}/${application}"></fileset>
</copy>
<property name="proj.compositeDir" value="${tmp.output.dir}/${application}/${current.time}"/>
<propertycopy name="proj.revision" from="${proj.compositeName}.version"/>
<property name="proj.enabled" value="${enabled}"/>
<echo>Deploying compositeDir: ${proj.compositeDir}</echo>
<echo>Deploying compositeName: ${proj.compositeName}</echo>
<echo>Deploying version: ${proj.revision}</echo>
<echo>Environment: ${targetenv}</echo>
<echo>Build Date: ${build.date}</echo>
<!--Checking if 11g or 12c code structure-->
<if>
<available file="${proj.compositeDir}/${proj.compositeName}/SOA" type="dir"/>
<then>
<property name="project.soa.dir" value="${proj.compositeDir}/${proj.compositeName}/SOA"/>
</then>
<else>
<property name="project.soa.dir" value="${proj.compositeDir}/${proj.compositeName}"/>
</else>
</if>
<!--Loading common .adf config file for targetenv MDS in META-INF-->
<property name="adfdir" value="${basedir}/config"/>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-package.xml" inheritAll="false" target="package">
<property name="compositeDir" value="${basedir}/${project.soa.dir}"/>
<property name="compositeName" value="${proj.compositeName}"/>
<property name="revision" value="${proj.revision}"/>
<property name="oracle.home" value="${oracle.home}"/>
<property name="java.passed.home" value="${java.passed.home}"/>
<property name="wl_home" value="${wl_home}"/>
<property name="sca.application.home" value="${basedir}/${proj.compositeDir}"/>
<property name="scac.application.home" value="${adfdir}"/>
<property name="scac.input" value="${project.soa.dir}/composite.xml"/>
<property name="scac.output" value="${tmp.output.dir}/${proj.compositeName}.xml"/>
<property name="scac.error" value="${tmp.output.dir}/${proj.compositeName}.err"/>
<property name="scac.displayLevel" value="3"/>
</ant>
<path id="cfgpln-file">
<fileset dir="${project.soa.dir}">
<include name="${proj.compositeName}_cfgplan_${targetenv}.xml"/>
</fileset>
</path>
<property name="deploy.configplan" refid="cfgpln-file"/>
<property name="deploy.sarLocation" value="${project.soa.dir}/deploy/sca_${proj.compositeName}_rev${proj.revision}.jar"/>
<property name="deploy.sarLocation" value="${project.soa.dir}/deploy/sca_${proj.compositeName}_rev${proj.revision}.jar"/>
<propertycopy name="deploy.overwrite" from="${targetenv}.overwrite"/>
<propertycopy name="deploy.user" from="${targetenv}.user"/>
<propertycopy name="deploy.password" from="${targetenv}.password"/>
<propertycopy name="deploy.forceDefault" from="${targetenv}.forceDefault"/>
<propertycopy name="deploy.server" from="${targetenv}.server"/>
<propertycopy name="deploy.port" from="${targetenv}.port"/>
<propertycopy name="deploy.serverURL" from="${targetenv}.serverURL"/>
<propertycopy name="deploy.partition" from="${application}.partition"/>
<echo>Deploying to ${deploy.serverURL} with user ${deploy.user}</echo>
<echo>sarFile: ${deploy.sarLocation}</echo>
<echo>Deploying with configPlan is ${deploy.configplan}</echo>
<echo>Server: ${deploy.server}</echo>
<echo>Port: ${deploy.port}</echo>
<echo>Partition/Folder: ${deploy.partition}</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="CompositeName: ${proj.compositeName}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Revision: ${proj.revision}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Partition: ${deploy.partition}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Deploy to ${deploy.serverURL} with user ${deploy.user}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Overwrite: ${deploy.overwrite}${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="forceDefault: ${deploy.forceDefault}${line.separator}" level="info"/>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-deploy.xml" inheritAll="false" target="deploy">
<property name="wl_home" value="${wl_home}"/>
<property name="oracle.home" value="${oracle.home}"/>
<property name="serverURL" value="${deploy.serverURL}"/>
<property name="user" value="${deploy.user}"/>
<property name="password" value="${deploy.password}"/>
<property name="overwrite" value="${deploy.overwrite}"/>
<property name="forceDefault" value="${deploy.forceDefault}"/>
<property name="sarLocation" value="${deploy.sarLocation}"/>
<property name="partition" value="${deploy.partition}"/>
<property name="configplan" value="${deploy.configplan}"/>
</ant>
<echo>Disable or Enable composite set to: ${composite.enable}</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="Composite enabled: ${composite.enable}${line.separator}" level="info"/>
<if>
<equals arg1="${composite.enabled}" arg2="false"/>
<then>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-mgmt.xml" inheritAll="false" target="stopComposite">
<property name="host" value="${deploy.server}"/>
<property name="port" value="${deploy.port}"/>
<property name="user" value="${deploy.user}"/>
<property name="password" value="${deploy.password}"/>
<property name="compositeName" value="${proj.compositeName}"/>
<property name="revision" value="${proj.revision}"/>
</ant>
</then>
</if>
<if>
<equals arg1="${composite.enabled}" arg2="true"/>
<then>
<ant antfile="${oracle.home}/../soa/bin/ant-sca-mgmt.xml" inheritAll="false" target="activateComposite">
<property name="host" value="${deploy.server}"/>
<property name="port" value="${deploy.port}"/>
<property name="user" value="${deploy.user}"/>
<property name="password" value="${deploy.password}"/>
<property name="compositeName" value="${proj.compositeName}"/>
<property name="revision" value="${proj.revision}"/>
</ant>
<echo>Unit Test project ${proj.compositeName}</echo>
</then>
</if>
<echo>${proj.compositeName}${proj.revision} deployment is complete.</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="Command Execution Status: SUCCESSFUL${line.separator}${line.separator}" level="info"/>
<if>
<matches pattern="true" string="${DeleteTemp}"/>
<then>
<echo>Cleaning temp folder: ./${tmp.output.dir}</echo>
<delete includeemptydirs="true">
<fileset dir="${tmp.output.dir}" includes="**/*"/>
</delete>
</then>
</if>
</then>
<else>
<echo>${proj.compositeName} deployment is skipping, check the property ${proj.compositeName}.deploy is set to false.</echo>
</else>
</if>
</try>
<catch>
<property name="exception" refid="exception_ref" />
<property name="message" value="ERROR IN TRYCATCH BLOCK:${exception}" />
<echo></echo>
<echo>${message}</echo>
<echo file="logs/instance-${log.date}.log" append="true" message="Command Execution Status: FAILED${line.separator}" level="info"/>
<echo file="logs/instance-${log.date}.log" append="true" message="Error message: ${message}${line.separator}${line.separator}" level="info"/>
</catch>
</trycatch>
</target>
</project>
8. Save All.
9. Open cmd/putty, and set ANT_HOME.
10. Execute command like ant -f deployAll -Dtargetenv=dev
Note:
a. Verify your path for all the ant sca xmls are correct.
b. Verify your adf-config.xml is correct.
Helpful? Please Comment.
Happy Learning!!
Hi nadim,
ReplyDeleteThanks for your blog!!
I have followed the steps as mentioned above but when i try to execute the command ant -f deployAll -Dtargetenv=dev
in windows cmd it is saying deployAll does not exist.
can you please share the build file you have created?
DeleteBuildfile:deployAll does not exist.
ReplyDeleteHi , anyone have ant build and deployment script for soa12c and osb 12c
ReplyDeleteHi Raju, Did you get any ant builds for 12c soa and OSB?
Delete