<?xml version="1.0" encoding="UTF-8"?>
<project name="MyProject" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<path id="maven-ant-tasks.classpath" path="D:\ant\lib\maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />
<property name="ssh_user" value="user"/>
<property name="ssh_pw" value="1111"/>
<!-- ======================================================== -->
<!-- app 배포 -->
<!-- ======================================================== -->
<target name="DEV_PAYMENT_RELEASE" depends="dev_ssh_host, set_property_payment, release" />
<target name="DEV_JSP_RELEASE" depends="dev_ssh_host, set_property_payment, jsp_release" />
<target name="dev_ssh_host"><property name="ssh_host" value="172.18.0.33"/></target>
<target name="set_property_payment"><property name="app_name" value="Payment"/></target>
<!-- ======================================================== -->
<!-- release -->
<!-- ======================================================== -->
<taskdef name="ssh" classname="com.sshtools.ant.Ssh" />
<target name="release">
<ssh host="${ssh_host}" port="22" username="${ssh_user}" password="${ssh_pw}" version="2">
<sftp action="put" remotedir="/home/nklee/${app_name}/webapps" verbose="true">
<fileset file="target/ROOT.war" />
</sftp>
<exec cmd="rm -rf /home/nklee/${app_name}/webapps/ROOT" />
<exec cmd="mkdir /home/nklee/${app_name}/webapps/ROOT" />
<exec cmd="cd /home/nklee/${app_name}/webapps" />
<exec cmd="ps -ef | grep ${app_name}/ | grep -v grep | awk '{ print$2}' | xargs kill" />
<exec cmd="unzip -o ROOT.war -d ./ROOT" />
<exec cmd="cd /home/nklee/${app_name}/tomcat/bin" />
<exec cmd="./startup.sh" />
</ssh>
</target>
<target name="jsp_release">
<ssh host="${ssh_host}" port="22" username="${ssh_user}" password="${ssh_pw}" version="2">
<sftp action="put" remotedir="/home/nklee/${app_name}/tomcat/webapps/ROOT/WEB-INF/view" verbose="true">
<fileset dir="WebContent/WEB-INF/view" />
</sftp>
</ssh>
</target>
</project>
maven-ant-tasks.jar 필요
출처: https://lng1982.tistory.com/245
댓글
댓글 쓰기