ant shell 实现增量减量部署.docx
《ant shell 实现增量减量部署.docx》由会员分享,可在线阅读,更多相关《ant shell 实现增量减量部署.docx(4页珍藏版)》请在冰豆网上搜索。
![ant shell 实现增量减量部署.docx](https://file1.bdocx.com/fileroot1/2022-12/31/8318e53b-c4bb-4f90-acac-18b2cd26d655/8318e53b-c4bb-4f90-acac-18b2cd26d6551.gif)
antshell实现增量减量部署
antshell实现增量减量部署
<copytodir="${add.dir}"verbose="false"failonerror="false"preservelastmodified="false"includeemptydirs="false"><filesetdir="${build.dir}">
<differenttargetdir="${old.dir}"ignoreFileTimes="true"/>
<presentpresent="both"targetdir="${old.dir}"/>
</fileset>
<filesetdir="${build.dir}">
<differenttargetdir="${old.dir}"ignoreFileTimes="true"/>
<presentpresent="srconly"targetdir="${old.dir}"/>
</fileset>
</copy>
<copytodir="${del.dir}"verbose="false"failonerror="false"preservelastmodified="false"includeemptydirs="false"><filesetdir="${old.dir}">
<differenttargetdir="${build.dir}"ignoreFileTimes="true"/>
<presentpresent="srconly"targetdir="${build.dir}"/>
</fileset>
</copy>
<sleepseconds="2"/>
<availablefile="../add"property="add.dir_exist"/>
<availablefile="../del"property="del.dir_exist"/>
<sleepseconds="1"/>
</target>复制代码判断是否要备份生产环境的该项目<targetname="needbak">
<conditionproperty="needbakup">
<or>
<issetproperty="add.dir_exist"/>
<issetproperty="del.dir_exist"/>
</or>
</condition>
<sleepseconds="1"/>
</target>
<targetname="bak_remote"if="needbakup">
<tstamp>
<formatproperty="DSTAMP"pattern="yyyyMMdd'T'HHmmss"/>
</tstamp>
<sshexechost="10.100.31.80"username="root"port="22"password=""command="zip-r/home/${project.name}-${DSTAMP}.zip${remote.dir}"trust="yes"/>
</target>复制代码将找到的需要删除的文件,修改为生产环境的路径,需要增加的文件,压缩为zip包<targetname="runsh"if="del.dir_exist">
<execexecutable="/bin/sh">
<argvalue="/home/dellist.sh"/>
<argvalue="s/^del/\/home\/tomcat\/webapps\/AMS/g"/>
</exec>
<sleepseconds="2"/>
</target><targetname="zip_package"if="add.dir_exist">
<zipdestfile="../add.zip"basedir="../add"/>
<sleepseconds="2"/>
<antcalltarget="addfile_scp"/>
</target>复制代码执行变更<targetname="del_remote"if="del.dir_exist">
<antcalltarget="delfile_scp"/>
</target>
<targetname="addfile_scp">
<scpfile="../add.zip"port="22"todir="root:
test@123@10.100.31.80:
/home"trust="yes"/>
<sshexechost="10.100.31.80"username="root"port="22"password="test@123"command="unzip-o/home/add.zip-d${remote.dir}"trust="yes"/>
</target><targetname="delfile_scp">
<scpfile="../del.txt"port="22"todir="root:
test@123@10.100.31.80:
/home"trust="yes"/>
<sshexechost="10.100.31.80"username="root"port="22"password="test@123"command="rm-f`cat/home/del.txt`"trust="yes"/>
</target>复制代码上传不了图片=。
=贴个jenkins的执行日志
clean:
prepare:
compile:
increment:
[copy]Copying14filesto/home/jenkins/jobs/test/workspace/add
[copy]Copying2filesto/home/jenkins/jobs/test/workspace/del
needbak:
bak_remote:
[sshexec]Connectingto10.100.31.80:
22
[sshexec]cmd:
zip-r/home/AMS-20130415T153408.zip/home/tomcat/webapps/AMS
[sshexec]adding:
home/tomcat/webapps/AMS/
[sshexec](stored0%)
[sshexec]adding:
home/tomcat/webapps/AMS/META-INF/(stored0%)
[sshexec]adding:
home/tomcat/webapps/AMS/META-INF/MANIFEST.MF
[sshexec](stored0%)runsh:
[exec]needdelfilefoundzip_package:
[zip]Buildingzip:
/home/jenkins/jobs/test/workspace/add.zipaddfile_scp:
[scp]Connectingto10.100.31.80:
22
[scp]done.
[sshexec]Connectingto10.100.31.80:
22
[sshexec]cmd:
unzip-o/home/add.zip-d/home/tomcat/webapps/AMS
[sshexec]Archive:
/home/add.zip
[sshexec]creating:
/home/tomcat/webapps/AMS/WEB-INF/page/ExtJs/app/period1/DataExtract/
[sshexec]inflating:
/home/tomcat/webapps/AMS/WEB-INF/classes/com/creditease/app/ams/period1/AMSConst.class
[sshexec]
[sshexec]inflating:
/home/tomcat/webapps/AMS/WEB-INF/classes/com/creditease/app/ams/period1/action/extjs/DataExtractAction.classdel_remote:
delfile_scp:
[scp]Connectingto10.100.31.80:
22
[scp]done.
[sshexec]Connectingto10.100.31.80:
22
[sshexec]cmd:
rm-f`cat/home/del.txt`bak:
[zip]Buildingzip:
/home/jenkins/jobs/test/workspace/build.zipincrement_all:
BUILDSUCCESSFUL
Totaltime:
1minute6seconds