[自动运维]ant脚本打包,上传文件到指定服务器,并部署
<project basedir="." default="build" name="othersysm">
</project>
<target depends="build-project" name="build"/>
<property name="ibslib.location" value="../ibslib"/><property name="debuglevel" value="source,lines,vars"/><property name="target" value="6"/><property name="source" value="6"/>
3、定义jar包路径,并命名,fileset表示引用外部包,pathelement表示内部
<path id="othersysm.classpath">
<pathelement path="{classpath}"/>
<fileset dir="${ibslib.location}/lib/logging" includes="**/*.jar,**/*.zip"/>
<pathelement location="bin"/> </classpath>
4、常用操作,新建文件夹使用mkdir,和拷贝文件使用copy
<target name="init">
<echo>
+=======================================+
| init
+=======================================+
</echo>
<mkdir dir="test"/>
<copy includeemptydirs="false" todir="test"><!--忽略空文件夹,并且拷贝到指定目录-->
<fileset dir="src" excludes="**/*.launch, **/*.java"/><!--忽略指定文件-->
</copy>
</target>
5、编译java文件,编译命令为:
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/><!-- 打印ant脚本目录 -->
<javac debug="true" debuglevel="${debuglevel}" destdir="test" source="${source}" target="${target}" encoding="UTF-8" includeantruntime="false">
<src path="src"/><!-- 源文件目录 -->
<classpath refid="othersysm.classpath"/><!-- classpath目录 -->
</javac>
</target>
6、在ant文件中该执行其他文件:
<ant antfile="${web.location}/build.xml" inheritAll="false" target="genwar" output="output.log"><property name="currentMode" value="${currentMode}"/><property name="targetMode" value="${targetMode}"/></ant>
7、file文件,表示读取properties文件,可以获取此文件中的属性值
<property file="${basedir}/build.properties"/>
<replaceregexp byline="true">
<regexp pattern="正则表达式"/>
<substitution expression="将要替换的值"/>
<fileset dir="${unpack.war.dir}/WEB-INF" includes="web.xml"/>
</replaceregexp>
<war destfile="${uibs.location}/web.war" webxml="WebContent/WEB-INF/web.xml"><fileset dir="WebContent" includes="**"/></war>
10、通过scp命令将上传war包文件到指定机器的指定目录
<scp file="${uibs.location}/${server.name}.war" todir="${wls.username}:${wls.password}@${remote.host}:${deploy.location}" trust="true"/>
11、远程ssh,执行服务器命令,执行启动脚本
<sshexec host="${remote.host}"
username="${remote.username}"
password="${remote.password}"
command="ls"
trust="true"/>
[自动运维]ant脚本打包,上传文件到指定服务器,并部署的更多相关文章
- Java实现上传文件到指定服务器指定目录
前言需求 使用freemarker生成的静态文件,统一存储在某个服务器上.本来一开始打算使用ftp实现的,奈何老连接不上,改用jsch.毕竟有现成的就很舒服,在此介绍给大家. 具体实现 引入的pom ...
- Java实现上传文件到指定服务器指定目录(ChannelSftp实现文件上传下载)
package com.tianyang.task.utils; import java.io.File;import java.io.FileInputStream;import java.io.I ...
- SpringBoot 上传文件到linux服务器 异常java.io.FileNotFoundException: /tmp/tomcat.50898……解决方案
SpringBoot 上传文件到linux服务器报错java.io.FileNotFoundException: /tmp/tomcat.50898-- 报错原因: 解决方法 java.io.IOEx ...
- C# 上传文件至远程服务器
C# 上传文件至远程服务器(适用于桌面程序及web程序) 2009-12-30 19:21:28| 分类: C#|举报|字号 订阅 最近几天在玩桌面程序,在这里跟大家共享下如何将本地文件上传 ...
- ASP.NET上传文件到远程服务器(HttpWebRequest)
/// <summary> /// 文件上传至远程服务器 /// </summary> /// <param name="url">远程服务地址 ...
- asp.net 服务器 上传文件到 FTP服务器
private string ftpServerIP = "服务器ip";//服务器ip private string ftpUserID = "ftp的用户名" ...
- 在C#客户端用HTTP上传文件到Java服务器
在C#客户端用HTTP上传文件到Java服务器 来源:http://www.cnblogs.com/AndyDai/p/5135294.html 最近在做C / S 开发,需要在C#客户端上传文件到 ...
- .Net 上传文件到ftp服务器和下载文件
突然发现又很久没有写博客了,想起哎呦,还是写一篇博客记录一下吧,虽然自己还是那个渣渣猿. 最近在做上传文件的功能,上传到ftp文件服务器有利于管理上传文件. 前面的博客有写到layui如何上传文件,然 ...
- java 上传文件到 ftp 服务器
1. java 上传文件到 ftp 服务器 package com.taotao.common.utils; import java.io.File; import java.io.FileInpu ...
随机推荐
- 【hadoop2.6.0】安装+例子运行
由于下载的是hadoop的最新版,网上各种杂七杂八的东西都不适用.好在官网上说的也够清楚了.如果有人看这篇文章的话,最大的忠告就是看官网. 官网2.6.0的安装教程:http://hadoop.apa ...
- 【Git】自定义Git
来源:廖雪峰 让Git显示颜色 git config --global color.ui true 忽略特殊文件 有些文件有敏感信息,或者是自动生成的中间文件.不能或不必提交到git,可以用.giti ...
- WinForm轻松实现自定义分页 (转载)
转载至http://xuzhihong1987.blog.163.com/blog/static/267315872011315114240140/ 以前都是做web开发,最近接触了下WinForm, ...
- POJ 2965 The Pilots Brothers' refrigerator
题目链接 题意:一个冰箱上有4*4共16个开关,改变任意一个开关的状态(即开变成关,关变成开)时,此开关的同一行.同一列所有的开关都会自动改变状态.要想打开冰箱,要所有开关全部打开才行. 输入:一个4 ...
- php Internal Server Error
Internal Server Error The server encountered an internal error or misconfiguration and was unable to ...
- 使用连发互联空间+SQLyog 设置我们的数据库链接
在我使用SQLyog(小海豚)管理我的数据库的时候,主机空间为连发互联的(自己做着玩,这个便宜),遇到一些坑,自己写一下记录一下,省的下次忘记了又浪费时间. 首先你要有连发互联的空间,可以淘宝购买,连 ...
- October 6th 2016 Week 41st Thursday
The outer world you see is a reflection of your inner self. 你拥有什么样的内心,你就会看到什么样的世界. And we eventually ...
- [Android]在代码混淆中关闭 Log
-assumenosideeffects class android.util.Log{ public static *** d(...); public static *** e(...); }
- CLR via C#(10)-参数
一. 命名参数.可选参数 命名参数和可选参数是在Visual C#2010中引入的新特性. 笨地儿我个瓜不兮兮的,今天才知道. 可选参数:定义方法时为参数设置默认值,调用该方法时可以省略为某些形参指定 ...
- 【JAVA多线程概述】
一.多线程概述 一个进程中至少有一个线程,每一个线程都有自己运行的内容,这个内容可以称为线程要执行的任务. 不能没一个问题都使用多线程,能使用单线程解决的问题就不要使用多线程解决. 使用多线程的弊端: ...