Eclipse+filesyncplugin+svn+jenkins+tomcat

Source: Internet
Author: User
Tags svn

Implement an idea to deploy the project on a Linux server and automatically sync to the server via svn+jenkins after the local eclipse code is updated.

Then through the Eclipse Remote Debug project. This solves the problem of running the project locally, causing the computer to change the card ... ^o^

Implementation ideas: Local projects--Local sync folder-->SVN Server-->jenkins for project build--reboot Tomcat

Well, not much to say, not too troublesome children's shoes can give it a try ...

  

  Environment Preparation :

(1) Installing the Filesyncplugin plugin in eclipse

Specific installation reference: Http://andrei.gmxhome.de/filesync/examples.html

(2) Configuring the SVN repository on the server

Specific reference: http://www.cnblogs.com/Vince-blogs/p/7477199.html

(3) Installing Jenkins on the server

Go to the Jenkins official website to install the war pack and put it on the server in Tomcat's WebApps directory.

  

  Configuration:

(1) Copy your project to another directory and upload the directory to SVN .

  (2) After installing the Filesyncplugin plugin in Eclipse, right click on your project and select Properties

Then click File Synchronization, then add folder to select the folders you want to update for your project.

Destination folder Select the folder for the top step

(3) Configuring Jenkins, I created two build item. A class, configuration file that is used to perform update server Tomcat, which requires the restart of Tomcat;

One for updating jsp,js,style files, etc., without restarting Tomcat on the server.

--------Multi-image alert--------

The item configuration where the update and restart Tomcat is as follows

The specific configuration is as follows, for reference only:

    

Where the shell script shutdown.sh to do is to close Tomcat, clear the cache, as follows

#!/bin/Bashprogram=tomcat-WEBSN=`PS-ef |grep$program |grep-Vgrep|awk '{print $}'' #获得进程端口号if["${SN}"!="" ]; #如果为空, indicating that the process did not start Then                Echo "${SN}"                Kill-9$SN #sudo-U tomcat/usr/local/apache/tomcat-web/bin/shutdown.SHfiTempfrdbase="/home/vince/tomcat-web/work/catalina/localhost/websockettest/"if[-D"$tempFRDBase" ];  Then             RM-rf"$tempFRDBase"fi

The ant script is as follows

<?XML version= "1.0" encoding= "UTF-8"?><Projectname= "XXXXX"default= "Norestartdeploy"Basedir=".">    <Echomessage= "Prepare for work-----" />        <!--define the project name -    < Propertyname= "Project.name"value= "XXXXX" />    <!--define the deployment path for the Web container -    < Propertyname= "Localwebserver.home"value= "/home/vince/tomcat-web" />    <!--define file Output path -    < Propertyname= "Outfiledir"value= "${localwebserver.home}/webapps" />    <!--Initialize Delete classes file -      <Targetname= "Restartinit">        <Echomessage= "====== Initialize ======" />        <Echomessage= "====== Delete Tomcat Project class file, path: ${outfiledir}/${project.name}/web-inf/classes/com ======" />        <Deletedir= "${outfiledir}/${project.name}/web-inf/classes/com" />    </Target>    <!--Initialize delete operation -      <!--the specific delete operation depends on the directory to be updated -     <Targetname= "Norestartinit">        <Echomessage= "====== Initialize ======" />        <Echomessage= "====== Delete the content to be updated (1): ${outfiledir}/${project.name}/js ======" />        <Deletedir= "${outfiledir}/${project.name}/js" />        <Echomessage= "====== Delete the content to be updated (2): ${outfiledir}/${project.name}/styles ======" />        <Deletedir= "${outfiledir}/${project.name}/styles" />        <Echomessage= "====== Delete the content to be updated (3): ${outfiledir}/${project.name}/web-inf/views ======" />        <Deletedir= "${outfiledir}/${project.name}/web-inf/views" />    </Target>        <!--Update class source files -    <Targetname= "Restartdeploy"depends= "Restartinit">        <Echomessage= "====== update source ======" />        <mkdirdir= "${outfiledir}/${project.name}/web-inf/classes/com" />        <CopyTodir= "${outfiledir}/${project.name}/web-inf/classes/com"Overwrite= "true">            <Filesetdir= "./com" />        </Copy>        <Echomessage= "====== code update complete, ready to restart Tomcat ======" />    </Target>    <!--do not restart, update non-classes files -      <Targetname= "Norestartdeploy"depends= "Norestartinit">        <Echomessage= "====== update code ======" />        <mkdirdir= "${outfiledir}/${project.name}/js" />        <mkdirdir= "${outfiledir}/${project.name}/styles" />        <mkdirdir= "${outfiledir}/${project.name}/web-inf/views" />        <CopyTodir= "${outfiledir}/${project.name}/js"Overwrite= "true">            <Filesetdir= "./js" />        </Copy>        <CopyTodir= "${outfiledir}/${project.name}/styles"Overwrite= "true">            <Filesetdir= "./styles" />        </Copy>        <CopyTodir= "${outfiledir}/${project.name}/web-inf/views"Overwrite= "true">            <Filesetdir= "./web-inf/views" />        </Copy>        <Echomessage= "====== Code update complete ======" />    </Target></Project>

Configuration ends. (The specific configuration depends on the situation ... ^O^)

Once the code is written, you need to submit the code to SVN in the local Sync folder and build the project using Jenkins

In this way, Eclipse is only used as an editor, and the debug program can be remotely debug with eclipse (refer to: http://www.cnblogs.com/Vince-blogs/p/7497011.html)

  

The END.

  

  

  

  

Eclipse+filesyncplugin+svn+jenkins+tomcat

Related Article

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.