Script to automate app deployment in WebLogic for OCI with Visual Builder Studio via bastion host


You have installed a WebLogic for OCI from Marketplace with a public bastion host included in the setup. You want to automate the deployment of an artefact automatic or manually. Proceed as follows:

Configure git repo:

Create parameters for all the variables in the script:

Create a build job with the following steps:

UNIX shell code example:

# BASTION_KEY in defined in the build job parameters tab
#
echo -e $BASTION_KEY > bastion.pem
chmod 400 bastion.pem
#
# to check that ssh jump works fine 
#
ssh -i bastion.pem -o StrictHostKeyChecking=no -o ProxyCommand="ssh -i bastion.pem -W %h:%p opc@@$BASTION_IP" opc@$WLSADMIN_NODE uptime
#
# this is the result of maven build
#
export WAR_FILE_PATH=`ls ./PWeb12/pweb/target/*.ear`
export WAR_FILE=`echo $WAR_FILE_PATH | sed 's:.*/::'`
export APP_NAME=`echo $WAR_FILE | sed "s/.ear//"`
echo "File to copy $WAR_FILE_PATH /mnt/wls/deploy/$WAR_FILE"
#
# copy the war/ear file to a shared disk that wls admin node can read, BASTION_IP is another variable defined in parameters tab
#
scp -i bastion.pem -o StrictHostKeyChecking=no $WAR_FILE_PATH opc@$BASTION_IP:/mnt/wls/deploy/dev
#
# change permissions to war/ear
#
ssh -i bastion.pem -o StrictHostKeyChecking=no -o ProxyCommand="ssh -i bastion.pem -W %h:%p opc@$BASTION_IP" opc@$WLSADMIN_NODE "sudo chmod 777 /mnt/wls/deploy/dev/pweb-1.0.0.ear"
#
# ssh via jumo host to execute deploy command
#
ssh -i bastion.pem -o StrictHostKeyChecking=no -o ProxyCommand="ssh -i bastion.pem -W %h:%p opc@$BASTION_IP" opc@$WLSADMIN_NODE "sudo su - oracle && /u01/jdk/bin/java -cp /u01/app/oracle/middleware/wlserver/server/lib/weblogic.jar weblogic.Deployer -adminurl t3://$WLSADMIN_NODE:9071 -user weblogic -password $WLS_PASSWORD -redeploy -source /mnt/wls/deploy/dev/$WAR_FILE -name $APP_NAME -targets wls_cluster"

Thats all, hope it helps! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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