jenkins------结合maven将svn项目自动部署到tomcat下

  • 下载Jenkins war包,下载地址

  • 配置Tomcat用户

    • 打开tomcat的conf目录下的tomcat-users.xml,修改成一下内容

      <?xml version='1.0' encoding='utf-8'?>
      <!--
        Licensed to the Apache Software Foundation (ASF) under one or more
        contributor license agreements.  See the NOTICE file distributed with
        this work for additional information regarding copyright ownership.
        The ASF licenses this file to You under the Apache License, Version 2.0
        (the "License"); you may not use this file except in compliance with
        the License.  You may obtain a copy of the License at
      
            http://www.apache.org/licenses/LICENSE-2.0
      
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
      -->
      <tomcat-users>
      <!--
        NOTE:  By default, no user is included in the "manager-gui" role required
        to operate the "/manager/html" web application.  If you wish to use this app,
        you must define such a user - the username and password are arbitrary.
      -->
      <!--
        NOTE:  The sample user and role entries below are wrapped in a comment
        and thus are ignored when reading this file. Do not forget to remove
        <!.. ..> that surrounds them.
      -->
      <!--
        <role rolename="tomcat"/>
        <role rolename="role1"/>
        <user username="tomcat" password="tomcat" roles="tomcat"/>
        <user username="both" password="tomcat" roles="tomcat,role1"/>
        <user username="role1" password="tomcat" roles="role1"/>
      -->
      <role rolename="admin-gui"/>
      <role rolename="admin-script"/>
      <role rolename="manager-gui"/>
      <role rolename="manager-script"/>
      <role rolename="manager-jmx"/>
      <role rolename="manager-status"/>
      <user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
      </tomcat-users>
  • 部署jenkins,将war包放到webapps便可

  • 打开jenkins,http://yourserver/jenkins/(这里我已经构建了项目)

    • 打开界面

    • 配置jdk和maven路径,在系统管理->系统配置

      • 配置jdk

      • 配置maven(不配置jvm参数很容易内存溢出)

    • 配置项目参数

      • 配置代码路径

      • 设置build参数,有个polling SCM能够设置定时构建,爱啥时候发布就是啥时候发布。用法点旁边的问号就行,和Quartz的表达式还有点不同。

      • 当即构建

      • 查看日志输出若是为下面的代表构建成功
  • 项目的pom文件添加Tomcat插件

    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <!-- 配置项目自动发布服务器 -->
            <path>/${project.build.finalName}</path>
            <update>true</update>
            <url>http://yourIp:yourPort/manager/text</url>
            <server>tomcat</server>
            <warFile>${basedir}/target/${project.build.finalName}.war</warFile>
            <uriEncoding>UTF-8</uriEncoding>
            <charset>UTF-8</charset>
        </configuration>
    </plugin>
相关文章
相关标签/搜索