jenkins+maven+tomcat+svn configuration notes (2) - building project

 

 After the basic configuration is completed, start building the project now , and select to build a maven2/3 project through the new left menu .

  To complete the automatic deployment to the tomcat container, you need to modify three configuration files, confirm before building:

   1. maven has permission to access the server tomcat (tomcat-user.xml of tomcat), configure the setting.xml file of maven;

   2. The maven project has been configured with the tomcat deployment plugin (tomcat-maven-plugin), which is the pom.xml file.

  Otherwise, the project files will not automatically go to the specified tomcat working directory. (Reference: http://siran.iteye.com/admin/blogs/2144758 ).

 

  Many of the rest are default options, here are some that need to be configured:

 

 

  Project name customization, source code management, select SVN here, fill in the address, enter the user name and password.

 



  

    Time periodical construction , select Poll SCM for automatic construction. The schedule here is to set how often to scan, the syntax refers to the syntax of cron.



 

 post steps select maven build here, then it will appear:

 

   Root pom: Specifies the pom file used when maven builds.

    Goals and options: MVN commands to be executed according to the actual situation. What is filled in here is:  clean install tomcat: redeploy
    is to clean first (if XX.war already exists under tomcat's webapps, delete it), then install, and finally deploy and publish after success. deployment command.

 



     选择配置好的maven对象,这里是之前的maven3.0.5。

 


   这里选择完成构建后自动部署到容器,然后会出现下图的选项(安装有tomcat插件才有这个):

 


     选择Deploy war/ear to a container。

     WAR/EAR files:注意在这里必须输入相对路径,不然会出现错误:"Expecting Ant GLOB pattern, but saw........."

   比如我的:/home/jenkins/workspace/hgs/target

   你只需要输入:target/hgs.war 红色部分之前的工作目录已经设置过,所以现在填写的就是你希望部署的工作目录。

     Containers 里的add Container,这里选择的是tomcat6.x。

   Manager user name和Manager password:容器Tomcat的管理员的账号和密码。

   URL:服务器tomcat的访问地址。

   现在用的是 Tomcat容器,需要事先修改配置文件“tomcat-users.xml”进行设置。(详细配置见:http://siran.iteye.com/admin/blogs/2144751)。

 

 

   上面的事情都做完后,现在可以点项目的立即构建,然后可以点击console output查看构建的日志,会在控制台输出构建的详细信息。

   看到success之后,查看tomcat的webapps目录下是否有你构建的xx.war和xx文件夹(该文件夹是由tomcat发布时解压产生的),访问项目,一切就OK啦。

 

 

 

  基础配置完成以后,现在就开始构建项目,通过新建左侧菜单,选择构建一个maven2/3项目

  要完成自动部署到tomcat容器需要修改三个配置文件,在构建之前确认:

   1.maven有访问服务器tomcat的权限(tomcat的tomcat-user.xml),配置maven的setting.xml文件;

   2.maven项目已经配置好tomcat部署插件(tomcat-maven-plugin),也就是pom.xml文件。

  不然项目的文件是不会自动到指定的tomcat工作目录下。(可以参考:http://siran.iteye.com/admin/blogs/2144758)。

 

  其余部分很多都是默认选项,下面提出一些需要配置的:

 

 

  项目名称自定义,源码管理 ,这里选择SVN,填写完地址,输入用户名和密码。

 



  

    时间周期性构建,自动构建的话选择Poll SCM。日程表这里是设置多久扫描一次,语法参照cron的语法。



 

 post steps 这里选择maven构建,然后就会出现:

 

    Root pom:指定maven 构建的时候使用的pom文件。

    Goals and options:根据实际情况执行的MVN命令。这里填写的是:  clean install tomcat:redeploy
    就是先进行clean(假如tomcat的webapps下已存在XX.war就删除) ,然后install ,最后在成功之后进行部署发布,顺序不要乱,install成功之后才调用tomcat的部署命令。

 



     选择配置好的maven对象,这里是之前的maven3.0.5。

 


   这里选择完成构建后自动部署到容器,然后会出现下图的选项(安装有tomcat插件才有这个):

 


     选择Deploy war/ear to a container。

     WAR/EAR files:注意在这里必须输入相对路径,不然会出现错误:"Expecting Ant GLOB pattern, but saw........."

   比如我的:/home/jenkins/workspace/hgs/target

   你只需要输入:target/hgs.war 红色部分之前的工作目录已经设置过,所以现在填写的就是你希望部署的工作目录。

     Containers 里的add Container,这里选择的是tomcat6.x。

   Manager user name和Manager password:容器Tomcat的管理员的账号和密码。

   URL:服务器tomcat的访问地址。

   The Tomcat container is now used, and the configuration file "tomcat-users.xml" needs to be modified in advance to set it. ( For detailed configuration, see: http://siran.iteye.com/admin/blogs/2144751).

 

 

  After the above things are done, you can now click the project's immediate build, and then you can click console output to view the build log, and the detailed information of the build will be output in the console.

   After seeing the success, check whether there are xx.war and xx folders you built in the webapps directory of tomcat ( the folder is generated by decompression when tomcat is released), access the project, and everything is OK.

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326449769&siteId=291194637