Jenkins deploy war file to Tomcat 8

两盒软妹~` 提交于 2019-12-17 18:29:20

问题


I'm running Jenkins 1.6 (and also tried with Jenkins 2.0) on the same server where I have Tomcat 8. I need to deploy Maven multimodule application to Tomcat webapp. It has two war files from submodules that has to be deployed. Deploy plugin supports Tomcat up to 7, and it's work fine. However, the problem is that I need to use Tomcat 8, since my web application is not working on Tomcat 7. Is it possible to deploy war files from Jenkins to Tomcat 8?


回答1:


Answer to your question

  1. Tomcat 7 deploy plugin can be used for Tomcat 8 and 9 deployment also, It will work 100%.
  2. Have to set authentication parameters with roles assigned should be set in tomcat-users.xml file (%TOMCAT8_PATH%/conf/tomcat-users.xml)
  3. Below sample code can be used for setting role based authentication in tomcat8 container.

                    <?xml version='1.0' encoding='utf-8'?>
                    <tomcat-users>
    
                        <role rolename="manager-gui"/>
                        <role rolename="manager-script"/>
                        <user username="admin" password="password" roles="manager-gui,manager-script" />
    
                    </tomcat-users>
    
  4. For Maven Authentication in this path %MAVEN_PATH%/conf/settings.xml

       <?xml version="1.0" encoding="UTF-8"?>
                <settings ...>
                    <servers>
    
                        <server>
                            <id>TomcatServer</id>
                            <username>admin</username>
                            <password>password</password>
                        </server>
    
                    </servers>
                </settings>
    
  5. Using Tomcat 7 Maven Plugin (Can be used for Tomcat 8 Deployments also)

                <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                            <url>http://localhost:8080/manager/text</url>
                            <server>TomcatServer</server>
                            <path>/yourappcontextpath</path>
                        </configuration>
                    </plugin>
    
  6. Deploy to tomcat can be performed any of these goals on need basis.
    mvn tomcat7:deploy
    mvn tomcat7:undeploy
    mvn tomcat7:redeploy

  7. Also, for more detailed logging you can enable java.util.logging.ConsoleHandler in logging.properties file %Tomcat_path%/conf/logging.properties.

                            org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
                            org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.ConsoleHandler
    
                            org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
                            org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = java.util.logging.ConsoleHandler
    
                            org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
                            org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = java.util.logging.ConsoleHandler
    


来源:https://stackoverflow.com/questions/37370927/jenkins-deploy-war-file-to-tomcat-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!