Jenkins Introduction and installation Please self-Baidu, this article focuses on how to use Jenkins, and automatically publish the Web app into Tomcat.
1. Create a project
Open Jenkins--new--fill in the item name, which is the project name, here I choose to build a free-style software project--Save
2. Configure the Build step
On the configuration page-->① source management I used the SVN, chose Subversion, fill in the project URL, first use Jenkins need to configure the SVN account password, configuration method according to the hint below.
② build triggers, I'll set up the hourly build once per hour
③ Configure the build step, where ant is used to build, select the ant version-ant1.9.5 is selected in the diagram, fill in tagets here Main is the corresponding Build.xml main target, so that the project will use the build. The XML is built on the line. After the build is finished, you need to publish the war package to Tomcat and add a shell step, OK.
Click Build now to see that the build is successful, and open the page to see the project.
Jenkins is relatively simple to use, and the key is to configure Ant Build.xml, which has not been contacted before. Web application compilation needs Servlet-api.jar, test a tomcat under the project Lib can be compiled to pass.
Attached build.xml rough, (⊙﹏⊙) B:
<?XML version= "1.0" encoding= "Utf-8"?><!--warning:eclipse auto-generated file. Any modifications would be overwritten. To include a user specific buildfile here, simply create one in the same directory with the processing Instru Ction <?eclipse.ant.import?> as the first entry and export the BuildFile again. -<ProjectBasedir="."default= "Main"name= "XX"> <Targetname= "Main"depends= "Complie, compress"Description= "Main target"> <Echo>Building War file.</Echo> </Target> < PropertyEnvironment= "env"/> < Propertyname= "DebugLevel"value= "Source,lines,vars"/> < Propertyname= "Target"value= "1.7"/> < Propertyname= "source"value= "1.7"/> <Targetname= "Init"> < Propertyname= "Build"value= "Build"></ Property> < Propertyname= "src"value= "src"></ Property> <Deletedir= "${build}" /> <mkdirdir= "${build}"/> <mkdirdir= "${build}\web-inf"/> <mkdirdir= "${build}\web-inf\classes"/> <CopyTodir= "${build}"> <Filesetdir= "${basedir}\webcontent"> <includename= "web-inf/**" /> <includename= "meta-inf/**" /> <includename= "api/**" /> <includename= "manage/**" /> </Fileset> </Copy> </Target> <!--defines the path to the LIB package since the project was compiled - <PathID= "Project.class.path"> <!--<pathelement path= "${classpath}"/> - <Filesetdir= "${basedir}/webcontent/web-inf/lib"> <includename= "**/*.jar" /> </Fileset> </Path> <Targetname= "Complie"depends= "Init"> <JavacSrcdir= "${basedir}/src"Destdir= "${build}/web-inf/classes"> <ClasspathrefID= "Project.class.path" /> </Javac> <CopyTodir= "${build}/web-inf/classes"> <Filesetdir= "${basedir}/src"> <includename= "**/**.xml" /> </Fileset> </Copy> </Target> <Targetname= "Compress"depends= "Complie"> <WarWarfile= "${build}/xx.war"Webxml= "${build}/web-inf/web.xml"> <Libdir= "${build}/web-inf/lib"/> <Classesdir= "${build}/web-inf/classes"/> <Filesetdir= "${build}"/> </War> </Target> </Project>
Use Jenkins and publish apps to Tomcat