57

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?

15
  • You don' get any messages (exception or not) related to the plugin? Feb 14, 2012 at 13:03
  • 1
    Theoretically - no. It's using Cargo, so it should be pretty straightforward. Still usually I got something in my job log in case of problems... Usually something like: ERROR: Publisher hudson.plugins.deploy.DeployPublisher aborted due to exception Feb 14, 2012 at 13:12
  • 1
    OK. Thanks for your time and effort, though!
    – whirlwin
    Feb 14, 2012 at 13:54
  • 2
    I was facing the same problem before. It was caused by the wrong path of war file. If you have folder like workspace/YourProjectname/target/warfile.war. The path should be target/warfile.war only.
    – syamimi
    Apr 16, 2013 at 7:18
  • 1
    @syamimi thanks, it helped me. But I wanted to know what if tomcat has different hosts, i.e. hosting multiple sites, in which case how to tell tomcat which host to deploy to ? Jun 7, 2013 at 21:16

7 Answers 7

105
+100

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.

1
  • Awesome, saved me the evening! I ran it to a third issue since my app is deployed with context root /. The plugin can't undeploy apps with the ROOT context root via the script manager. I wrote a few lines on how to handle it via having a second context root. macgyverdev.blogspot.se/2014/02/… Feb 4, 2014 at 21:20
8

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

6
  • Great suggestion. I'll try that tomorrow. I'll probably leave the bounty open to see if anyone has a solution using the deploy plugin. Mar 29, 2012 at 0:49
  • 2
    instead of passing user:pass directly I would suggest to use the parameter --netrc to read the user:pass from .netrc file, so passwords won't show up in jenkins logs!
    – Matthias B
    Dec 23, 2012 at 23:46
  • The command-line reproduction of plugin activity is super helpful for debugging. Thanks!
    – Yonatan
    Nov 24, 2013 at 8:59
  • HI German, I am not able to deploy war by jenkins war plugin, but this work for me. One issue: jenkins hang after fire curl command any idea? Nov 27, 2015 at 15:37
  • Jenkins will wait for a response from tomcat. Check your tomcat Nov 27, 2015 at 18:56
1

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.

2
  • Oh, I think i read fast, are you using maven separately in your project? :) or when you wrote (maven) you mean the output of jenkins?
    – anvarik
    Mar 29, 2012 at 13:25
  • I'm building with maven, and not currently using cargo. I tried to configure it for a while, but after some failures decided to abandon that approach. Mar 29, 2012 at 13:59
1

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

0

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.

0

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

0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.