X
  • Tips |
    August 17, 2016

Bash script to deploy webapp to Weblogic server domain via WLST

I wrote a bash script to deploy a war file to ALL managed servers in a Weblogic domain. You should be able to modify it to work for your needs.

#!/bin/bash
HOST_NAME=${1-localhost}
HOST_USER=${2-weblogic}
HOST_PASS=${3-welcome1}
HOST_PORT=${4-7001}
JAVA_BIN="/usr/bin/java"
SCRIPT_HOME="$(dirname $(readlink -f $0))"
WL_JAR="${SCRIPT_HOME}/middleware/wlserver_10.3/server/lib/weblogic.jar"
JAM_JAR="myapp.war"
function getServerList()
{
WLST_SERVER_LIST=$(${JAVA_BIN} -cp ${WL_JAR} weblogic.WLST <<EOF
connect("${HOST_USER}", "${HOST_PASS}", "t3://${HOST_NAME}:${HOST_PORT}")
cd('Servers')
ls('a')
EOF
)
SERVER_LIST=""
while read -r CURR_LINE; do
if [[ ${CURR_LINE} =~ drw-* ]]
then
SERVER_LIST+=$(printf ${CURR_LINE#*drw-},)
fi
done <<< "${WLST_SERVER_LIST}"
SERVER_LIST=${SERVER_LIST%,*}
#echo $SERVER_LIST
}
function agentDeployer()
{
${JAVA_BIN} -cp ${WL_JAR} weblogic.Deployer -adminurl t3://${HOST_NAME}:${HOST_PORT} -user ${HOST_USER} -password ${HOST_PASS} -targets ${SERVER_LIST} -deploy -upload ${JAM_JAR}
}
echo "Deploying"
getServerList
agentDeployer
 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services