一、maven环境搭建
1、maven下载
Maven的下载地址: http://maven.apache.org/download.cgi
2、环境配置
修改环境变量,在/etc/profile中添加以下几行
MAVEN_HOME=/usr/local/maven3 export MAVEN_HOME export PATH=${PATH}:${MAVEN_HOME}/bin
记得执行 source /etc/profile
使环境变量生效。
3、修改setting配置文件,配置仓库位置和私有仓库地址
二、svn下载代码
第一次需要输入用户名,密码,然后记住密码即可
cd /usr/local/svn_auto_deploy/source;
/usr/bin/svn co --username xxx--password xxx--no-auth-cache http://xxx/svn/source;
三、maven构建war包
1、构建命令
cd /usr/local/svn_auto_deploy/source/code-parent;
mvn clean install -Psit -e;
2、mavn pom.xml 指定war包名称
<!-- war打包插件, 设定war包名称不带版本号 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>code-soa</warName>
</configuration>
</plugin>
四、命令集合
1、命令
cd /usr/local/svn_auto_deploy/source;
svn update;
cd /usr/local/svn_auto_deploy/source/code-parent;
mvn clean install -Psit -e;
ls;
rm /usr/local/nginx/sbin/*.war -rf;
cp /usr/local/svn_auto_deploy/source/code-cos/target/code-cos.war /usr/local/nginx/sbin/code-cos.war;
cp /usr/local/svn_auto_deploy/source/code-api/target/code-api.war /usr/local/nginx/sbin/code-api.war;
cp /usr/local/svn_auto_deploy/source/code-cms/target/code-cms.war /usr/local/nginx/sbin/code-cms.war;
cp /usr/local/svn_auto_deploy/source/code-soa/target/code-soa.war /usr/local/nginx/sbin/code-soa.war;
cd /usr/local/nginx/sbin;
ls;
sh deploy_all.sh;
2、deploy_all.sh
来源:oschina
链接:https://my.oschina.net/u/1265394/blog/690233