Some Configuration (deploy.conf)
#Enter the package location heresource=/data/Jenkins_builds/MMT
#Enter the server IP here
FEServer=<fronend-ip-server>
BEServer=<backend-ip-server>
#Enter the target name here
FETarget=Server-0
BETarget=Server-2
#Enter package name
FEPackage=atm-ui-portlet
BEPackage=mmt-ws
#Enter the source path here
FEPath=/data/deployment/portal_destination
BEPath=/data/deployment
#Enter the portal deploy path here
PortalDeploy=/data/deployment/portal_deploy
Auto deploy script
#!/bin/bashLogfile="logAutoDeploy.txt"
. ./deploy.conf
echo [$(date)]: ============Starting to auto deploy========== >> $Logfile
if [ -f $source/$BEPackage.war ]; then
echo [$(date)]: ============Deploy Backend package========== >> $Logfile
echo undeploy the package $BEPackage
java -classpath /data/weblogic/wlserver_10.3/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://$BEServer:7001 -user <user-name> -password <password> -undeploy -name $BEPackage
echo the package $BEPackage is undeployed >> $Logfile
echo delete the package $BEPath/$BEPackage >> $Logfile
cd $BEPath
rm -rf $BEPackage
mkdir $BEPackage
cd $BEPackage
echo copy $BEPackage package to $BEPath/$BEPackage >> $Logfile
cp $source/$BEPackage.war ./
echo unzip $BEPackage package >> $Logfile
unzip $BEPackage.war
rm -f $BEPackage.war
echo deploy $BEPackage to back end server >> $Logfile
java -classpath /data/weblogic/wlserver_10.3/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://$BEServer:7001 -user <user-name> -password <password> -deploy $BEPath/$BEPackage -targets $BETarget
echo remove $BEPackage war file in Jenkins build >> $Logfile
cd $source
mv $BEPackage.war tmp
fi
if ls $source/$FEPackage* 1> /dev/null 2>&1; then
echo [$(date)]: ============Deploy Frontend package========== >> $Logfile
echo undeploy the package $FEPackage >> $Logfile
java -classpath /data/weblogic/wlserver_10.3/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://$FEServer:7001 -user <user-name> -password <password> -undeploy -name $FEPackage
echo the package $FEPackage is undeployed >> $Logfile
echo delete the package $FEPackage >> $Logfile
cd $FEPath
rm -rf $FEPackage*
echo copy the $FEPackage to $PortalDeploy >> $Logfile
scp $source/$FEPackage* $PortalDeploy
echo waiting to Liferay extracts the package >> $Logfile
sleep 10
echo deploy $FEPackage to server >> $Logfile
java -classpath /data/weblogic/wlserver_10.3/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://$FEServer:7001 -user <user-name> -password <password> -deploy $FEPath/$FEPackage -targets $FETarget
echo remove $FEPackage war file in Jenkins build >> $Logfile
cd $source
mv $FEPackage* tmp
fi
No comments:
Post a Comment