安装ant可以参考下这个 http://t.csdn.cn/kx1ZX
第一个错误,原因是缺少ant-contrib.jar导致,将对应jar包放入ant的lib下即可
[taskdef] Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found.
BUILD FAILED
第二个错误,原因是缺少SVN对应jar包导致,将对应jar包放入ant的lib下即可
Buildfile: /home/weblogic/upgrade_scripts/sales_build_release.xml
[typedef] Could not load definitions from resource org/tigris/subversion/svnant/svnantlib.xml. It could not be found.
[typedef] Could not load definitions from resource org/tigris/subversion/svnant/svnantlib.xml. It could not be found.
第三个错误 ,原因是缺少jsch jar包导致,将对应jar包放入ant的lib下即可
BUILD FAILED
/home/weblogic/upgrade_scripts/test_build_release.xml:25: Problem: failed to create task or type scp
Cause: Could not load a dependent class com/jcraft/jsch/Logger
ant配置,只需要将文件打包放svn,然后进入脚本目录,运行即可
cd /home/weblogic/test_scripts
ant -buildfile test_build_release.xml -Dv=v2.0.1.1_20230505_test
<project name="test_manage_patch" default="deploy">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<property name="backup_path" value="/data/zstest/backupfiles/test_manage/v2.0" /><!-- 设置备份路径!-->
<property name="app_path" value="/data/Application/v2.0" />
<property name="backup_filename" value="test_manage${v}.jar" />
<propertyregex property="patch_version" input="${v}" regexp="(.{4})" select="\1" />
<property name="patch_sub_version" value="${v}" />
<target name="clean">
<delete dir="target" quiet="true" />
<mkdir dir="target" />
</target>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpath="svnant.jar" />
<target name="checkoutfileList" depends="clean">
<!--svn地址及密码-->
<svn javahl="true" username="svnname" password="svnpass" failonerror="false">
<export srcUrl="svn://10.110.15.21/test/test_manager/patch/${patch_version}/${patch_sub_version}/目标代码/fileList" destPath="target" />
</svn>
</target>
<target name="upload_fileList" depends="checkoutfileList">
<!--158的服务器及密码、系统文件地址-->
<scp file="target/fileList" todir="weblogic:Weblogicpass@10.110.15.158:/data/Application/v2.0" trust="true" />
</target>
<target name="backupfiles" depends="upload_fileList">
<!--158的服务器及密码、JDK路径-->
<sshexec host="10.110.15.158" username="weblogic" failonerror="false" password="Weblogicpass" command="cd ${app_path};export JAVA_HOME=/data/EnvironmentConfig/jdk1.6/jdk1.6.0_113;export PATH=$JAVA_HOME/bin:$PATH;CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar; jar -cvf ${backup_path}/${backup_filename} @fileList " trust="true" />
</target>
<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpath="svnant.jar" />
<target name="checkout" depends="backupfiles">
<svn javahl="true" username="svnname" password="svnpass" failonerror="false">
<export srcUrl="svn://10.110.15.21/test/test_manage/patch/${patch_version}/${patch_sub_version}/目标代码/test_manage.zip" destPath="target" />
</svn>
</target>
<target name="upload_patch" depends="checkout">
<scp file="target/test_manage.zip" todir="weblogic:Weblogicpass@10.110.15.158:/data/Application/v2.0" trust="true" />
</target>
<target name="testSSHEXEC" depends="upload_patch">
<sshexec host="10.110.15.158" username="weblogic" password="Weblogicpass" command="cd ${app_path}; unzip -o test_manage.zip ;rm -rf test_manage.zip;rm -rf fileList" trust="true" />
</target>
<property name="wl.home" value="/data/Oracle/Middleware/wlserver_10.3" /><!--157服务器上的weblogic地址-->
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<fileset dir="${wl.home}/server/lib">
<include name="*.jar" />
<exclude name="jrmp.jar" />
<exclude name="jrmpclient.jar" />
</fileset>
</classpath>
</taskdef>
<target name="deploy" depends="testSSHEXEC">
<wldeploy action="redeploy" verbose="true" debug="true" name="test_v2" source="${app_path}/test_v2.0" user="weblogic" password="weblogicpass" adminurl="t3://10.110.15.158:7011" targets="zstest158" />
<echo>Update Success!</echo>
</target>
<target name="undo_patch">
<sshexec host="10.110.15.158" username="weblogic" password="weblogicpass" command="cd ${backup_path};cp ${backup_filename} ${app_path}; export JAVA_HOME=/data/EnvironmentConfig/jdk1.6/jdk1.6.0_113;export PATH=$JAVA_HOME/bin:$PATH;CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar; cd ${app_path}; jar -xvf ${backup_filename} ; rm -rf ${backup_filename}" trust="true" />
</target>
<target name="undo_deploy" depends="undo_patch">
<wldeploy action="redeploy" verbose="true" debug="true" name="test_v2.0" source="${app_path}/test_v2.0" user="weblogic" password="weblogicpass" adminurl="t3://10.110.15.158:7011" targets="zstest158" />
<echo>Undo_redeploy Success!</echo>
</target>
</project>