Jenkins auto deploy tomcat 7

后端 未结 7 501
生来不讨喜
生来不讨喜 2020-12-22 19:18

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 config

相关标签:
7条回答
  • 2020-12-22 19:42

    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.

    0 讨论(0)
  • 2020-12-22 19:51

    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 讨论(0)
  • 2020-12-22 19:56

    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

    0 讨论(0)
  • 2020-12-22 19:58

    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.

    0 讨论(0)
  • 2020-12-22 19:58

    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 讨论(0)
  • 2020-12-22 19:59

    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 讨论(0)
提交回复
热议问题