Jenkins auto deploy tomcat 7

JavaTomcatMavenJenkinsTomcat7

Java Problem Overview


We're trying to deploy a war file with Jenkins, but nothing seems to happen.

The project is built successfully, and we're using Jenkins deploy plugin. It is configured with the following options:

auto deploy plugin

Post steps are set to "run regardless of build result".

I have checked that the credentials are correct, as I can acces the manager page in my browser.

Here is the last part that Jenkins (Maven) outputs:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:24.506s
[INFO] Finished at: Tue Feb 14 12:10:45 UTC 2012
[INFO] Final Memory: 22M/52M
[INFO] ------------------------------------------------------------------------
channel stopped
Finished: SUCCESS

I can also change WAR/EAR file to something that doesn't exist, and it will not give me errors, which is kind of strange. What am I doing wrong here?

Java Solutions


Solution 1 - Java

I was having the same problem, and in my case the (relative) path to the WAR file was incorrect. Apparently if you don't have it exactly correct (it needs to be relative to the workspace root) then the deploy plugin will silently fail. In my case the path was:

target/whatever.war

Once that was fixed, I ran into a different problem in that the plugin expects to connect to the manager/text version of Tomcat Manager, rather than the manager/html version that I usually configure by default. You'll need a line in your tomcat-users.xml file like the following:

<user username="tomcat" password="pencil" roles="manager-script"/>

(This is in addition to the "manager-gui" role you probably already have set up.)

Once those changes were made, the build and deployment worked just fine.

Solution 2 - Java

> I use the Hudson Post Build Task plugin to execute a curl against the /manager/text API > > The plugins mentioned can be selected and > installed from the list of available plugins in the Jenkins configuration.

Once you have the plugin installed you just need to enable the "Post build task" and add the next line:

curl -T - -u user:pass 'http://<tomcat-host>/manager/text/deploy?update=true&path=/<yourpath>' < <path_to_war_file>

For example:

curl -T - -u manager:123456 'http://localhost:8080/manager/text/deploy?update=true&path=/slim' < /target/dist/slim.war

You can also use wget, but with the command above you log the output and see if there was a problem with the deploy.


Here's documentation related to the /manager/text service

Solution 3 - Java

Hm have you used Cargo plugin? Well, I also had the same configuration as you, Jenkins, maven and tomcat. But when I needed to deploy, I was simply using that plugin. It's been a while actually, but in Jenkins you were able to enter command prompt lines right? Like mvn clean install? So, what you can do is simply configure your pom for Cargo plugin and then add that line to your Jenkins:

mvn cargo:deploy -Pintegration

By this way, I was able to clean install my builds daily, and deploy them to Tomcat. Afterwards I was doing my rest tests.

Solution 4 - Java

For what it's worth, the latest version of the Deploy plugin for Jenkins seems to only need the base url. So, for me, it was http://blah.com:8080

Before that, I'd tried a host of other options, including host-manager/html, host-manager/text

Solution 5 - Java

Assuming that Jenkins is finding your pom.xml to compile. Set your Goals and options in your Jenkins configuration to compile package. Then Jenkins will attempt to find your war file and deploy it. Good Luck.

Solution 6 - Java

I tried to use the solution of target/whatever.war but it's not work so i tried to use **/*.war and it's work

you can see that on jenkins the definitive guide EN You need to specify where to find the files you want in the other build job’s workspace, and where Jenkins should put them in your current project’s workspace. This can be a flexible regular expression (such as */.war, for any WAR file produced by the build job), or it can be much more precise (such as gameoflife-web/target/gameoflife.war).

or on Deploy to Tomcat with pluging DEPLOY

Solution 7 - Java

keep the roles manager-gui,admin-gui for the user who was configured Jenkins page

example:-

 <tomcat-users>

   <user username="uname" password="pword" roles="manager-gui,admin-gui"/>

 </tomcat-users>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwhirlwinView Question on Stackoverflow
Solution 1 - JavaBill ClarkView Answer on Stackoverflow
Solution 2 - JavaGerman AttanasioView Answer on Stackoverflow
Solution 3 - JavaanvarikView Answer on Stackoverflow
Solution 4 - JavaAHungerArtistView Answer on Stackoverflow
Solution 5 - JavaQuesoView Answer on Stackoverflow
Solution 6 - Javanizar ouerghiView Answer on Stackoverflow
Solution 7 - JavaVenky VungaralaView Answer on Stackoverflow