Using cargo to implement Jenkins automatic deployment of remote Tomcat

Source: Internet
Author: User

Reprint please indicate the source:
http://blog.csdn.net/ouyida3/article/details/48089141
This article is from: "Ouyida3 's Blog"

Tomcat-users.xml Configuration
<role rolename="manager"/><role rolename="Manager-script"/> <role rolename="Manager-gui"/> <role rolename="manager-jmx"/><role rolename="Manager-status"/>  <user username="admin" password="admin" roles= "Manager,manager-gui,manager-script,manager-jmx,manager-status"/>
Pom.xml Configuration
<plugin>    <groupId>Org.codehaus.cargo</groupId>    <artifactid>Cargo-maven2-plugin</artifactid>    <version>1.4.15</version>    <configuration>        <container>            <containerid>tomcat8x</Containerid>            <type>Remote</type>        </container>        <configuration>            <type>Runtime</type>            <properties>                <cargo.tomcat.manager.url>Http://32.20.115.125:8080/manager</cargo.tomcat.manager.url>                <cargo.remote.username>Admin</cargo.remote.username>                <cargo.remote.password>Admin</Cargo.remote.password>                <cargo.servlet.port>8080</cargo.servlet.port>                <cargo.hostname>32.20.115.125</cargo.hostname>                <cargo.tomcat.ajp.port>8009</cargo.tomcat.ajp.port>            </Properties>        </configuration>    </configuration></plugin>
Test command

MVN Cargo:redeploy

Success:

F:\code\BSS_gd-trunk\mapp\zsale\zsale-WEB&GT;MVN Cargo:redeploy[INFO]Scanning for projects ...[INFO][INFO]------------------------------------------------------------------------[INFO]Building Zsale-web 0.0.1-snapshot[INFO]------------------------------------------------------------------------[INFO][INFO]---cargo-maven2-plugin:1.4.15:redeploy (default-cli) @ zsale-web---[INFO] [Deployerredeploymojo]Resolved container artifact org.codehaus.cargo:cargo-core-container-tomcat:jar:1.4.15 for container tomcat8x[INFO] [Mcat8xremotedeployer]Redeploying[F:\code\BSS_gd-trunk\mapp\zsale\zsale-web\target\zsale-web-0.0.1-snapshot.war][INFO] [Mcat8xremotedeployer]Undeploying[F:\code\BSS_gd-trunk\mapp\zsale\zsale-web\target\zsale-web-0.0.1-snapshot.war][INFO] [Mcat8xremotedeployer]Deploying[F:\code\BSS_gd-trunk\mapp\zsale\zsale-web\target\zsale-web-0.0.1-snapshot.war][INFO]------------------------------------------------------------------------[INFO]BUILD SUCCESS[INFO]------------------------------------------------------------------------[INFO]Total time:38.813 S[INFO]Finished at:2015-08-29t17:23:50+08:00[INFO]Final memory:6m/17m[INFO]------------------------------------------------------------------------

PS: First run will download cargo related jar

Error resolution method

Run MVN cargo:redeploy Error

caused By:java.net.ConnectException:Connection refused:connect
At Org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke (tomcatmanager.java:534)

If Tomcat does not start, it will also report the error. If you start and report this error, first visit through the browser to see if it is OK. Because the code is using Httpconnection to connect.

To view the source code, see below

If the browser is accessible, the configuration is wrong.
Note : Cargo.hostname is mandatory if not configured by default is localhost! In other words, what is configured in the Cargo.tomcat.manager.url is not working. The port is also the same, to be configured.

Source Code View method

Assuming that this version of Cargo-core-container-tomcat-1.4.9.jar is used, you can rely on the jar in Pom.xml and execute the command mvn dependency:sources. This command will download the source code for the jar that the Pom.xml relies on, of course, if the jar itself is not provided with the source code will not be downloaded, the execution of the command will prompt which downloaded which are not downloaded.

Spit The Groove.

Xu Xiaobin's "Maven Live" book is really good. However, the section on cargo remote deployment is a bit perfunctory! Just list A localhost configuration example, obviously remote deployment, how can you use localhost as an example? Made me because of this led to connection refused mistake to get a half a day to fix.

User name password error

Caused by:org.codehaus.cargo.container.tomcat.internal.TomcatManagerException:
The username and password you provided is not correct (Error 401)

If the user name password is wrong, this error is reported.

About versions

I tried the 1.4.9 and the newest 1.4.15 were no problem.
Tomcat I'm using Tomcat8,containerid tried both tomcat7x and tomcat8x can (tomcat9x of course not). Prove that the tomcat7x configuration is also compatible with TOMCAT8.

Reference

Jenkins deploys Tomcat
http://wxynxyo.iteye.com/blog/1909110 a picture of Jenkins
http://my.oschina.net/congqian/blog/112782
Http://blog.sina.com.cn/s/blog_b5fe6b270102v7xi.html not tried, it seems to be very convenient

Cargo
http://zhouhaitao.iteye.com/blog/1997135
http://blog.csdn.net/steveguoshao/article/details/38469713 more detailed
http://www.codeweblog.com/use-maven-cargo-plugin-manager-deployment-tomcat6/more detailed, but English (this article solves my big problem)

Cargo official Website:
Https://codehaus-cargo.github.io/cargo/Home.html
http://cargo.codehaus.org/(formerly official website, now automatically jump)

Extended-capitomcat

Capitomcat is a plugin for Jenkins and is said to deploy Tomcat. But it was a wall! I didn't try.

Ruby Runtime Plugin Wait
Capitomcat Plugin Wait
Restart Jenkins Wait
Failed to connect to http://www.google.com/. Perhaps need to

In addition, cargo deployment is divided into remote deployment and on-premises deployment. This article only describes the former, because the latter is of little significance in the production environment. Local deployment is relatively simple, see Xu Xiaobin's book "Maven Combat" or online examples.

Reprint please indicate the source:
This article is from: "Ouyida3 's Blog"
2015.8.29

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Using cargo to implement Jenkins automatic deployment of remote Tomcat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.