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?
Jenkins deploy war file to Tomcat 8
Asked Answered
Answer to your question
- Tomcat 7 deploy plugin can be used for Tomcat 8 and 9 deployment also, It will work 100%.
- Have to set authentication parameters with roles assigned should be set in tomcat-users.xml file (%TOMCAT8_PATH%/conf/tomcat-users.xml)
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>
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>
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>
Deploy to tomcat can be performed any of these goals on need basis.
mvn tomcat7:deploy
mvn tomcat7:undeploy
mvn tomcat7:redeployAlso, 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
Deploy container plugin is perfectly working fine with tomcat 9 as well. –
Carper
I keep on getting: IO Exeption Broken pipe (Write failed) could someone help me with this? –
Divorcement
Downvote. Doesn't work. Tomcat will give "Caused by: java.net.BindException: Address already in use" and Jenkins will give "Caused by: java.net.SocketException: Connection reset". Please update. –
Minnaminnaminnie
[INFO] --- tomcat7-maven-plugin:2.2:undeploy (default-cli) @ gs-serving-web-content --- [INFO] Undeploying application at localhost:8081/gs-serving-web-content SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See slf4j.org/codes.html#StaticLoggerBinder for further details. [INFO] FAIL - No context exists named [/gs-serving-web-content] –
Minnaminnaminnie
[INFO] --- tomcat7-maven-plugin:2.2:deploy (default-cli) @ gs-serving-web-content --- [INFO] Deploying war to localhost:8081 Uploading: localhost:8081/manager/text/deploy?path=%2F Uploading: localhost:8081/manager/text/deploy?path=%2F Uploading: localhost:8081/manager/text/deploy?path=%2F Uploading: localhost:8081/manager/text/deploy?path=%2F [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE –
Minnaminnaminnie
Bind Exception "Already in use" Means, similar process using the same port. Please change your port to 9081 or some other number. It will work. –
Bonnie
© 2022 - 2024 — McMap. All rights reserved.