jenkins简单持续集成更新

  • 来源:
  • 更新日期:2018-04-25

摘要:1、所需插件名称 Deploy to container Plugin Jenkins SSH plugin 2、pom profiles配置                            true            

1、所需插件名称

Deploy to container Plugin

Jenkins SSH plugin

002UASMrzy7605pjKJv15&690.jpg

2、pom profiles配置

<profiles> <profile> <activation> <activeByDefault>true</activeByDefault> </activation> <id>develop</id> <properties> <jdbc.username>root</jdbc.username> …… </properties> …… </profile> …… </profiles> <!--包含的资源目录--> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <webResources> <resource> <filtering>true</filtering> <directory>src/main/webapp</directory> <includes> <include>**/*.xml</include> </includes> </resource> </webResources> </configuration> </plugin> </plugins> </build>

 

3、maven 打包参数 :clean install -P test

4、Deploy to container Plugin使用配置

5、新建执行更新服务器的shelljob

#关闭指定端口号的tomcat netstat-antp|awk\'/:9080/{print$NF}\'|awk-F\'/\'\'{print$1}\'|xargskill-9 #切换到tomcat目录 cd/home/appuser/apache-tomcat-x/ #删除tomcat日志logs文件夹里的全部文件 rm-frlogs/* #删除tomcatjsp文件缓存 rm-rfwork/Catalina/* #删除上一次备份应用部署文件 rm-rfbak/*~ #删除上一次备份应用war文件 rm-rfwar/*~ #将应用移到bak文件夹备份 mv-fbwebapps/w/xbak #将发布的应用war移到war目录下备份 mv-fbwebapps/tomcat/x.warwar #将发布的应用移到指定的虚拟主机下 mv-fbwebapps/tomcat/xwebapps/w/ #启动tomcat ./bin/startup.sh