Automatically deploy projects using the Wagon-maven-plugin plugin

Source: Internet
Author: User
Tags ssh tomcat

The plugin's maven dependency is:

<dependency>  
    <groupId>org.codehaus.mojo</groupId>  
    <artifactId> wagon-maven-plugin</artifactid>  
    <version>1.0</version>  
</dependency>  

The document address of the plugin is:
http://www.mojohaus.org/wagon-maven-plugin/

Mainly provides the following several goal
Wagon:upload-single uploads the specified file to a remote location.
Wagon:upload uploads the specified set of files to a remote location.
Wagon:download-single downloads the specified file from a remote location.
Wagon:download downloads the specified set of files from a remote location.
Wagon:list lists the content of a specified location in a remote repository.
Wagon:copy copies a set of files under a wagon repository to another.
Wagon:merge-maven-repos merges, including metadata, a Maven repository to another.
Wagon:sshexec executes a set of commands at remote SSH host.

Use the following:

In order for the Wagon-maven-plugin plugin to ssh into a Linux server, you first need to configure the server's user name and password in MAVEN configuration file settings.xml.

<server>  
    <id>webserver</id>  
    <username>hadoop</username>  
    <password >123</password>  
</server>  

With this plugin, you need to configure the following in the build

<extensions>  
    <extension>  
        <groupId>org.apache.maven.wagon</groupId>  
        < artifactid>wagon-ssh</artifactid>  
        <version>2.10</version>  
    </extension>  
</extensions>  

The following shows a procedure for deploying a war to Tomcat using the query

<build> <finalName>osc-shop</finalName> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactid>wagon-ssh</artifactid&gt  
            ;  
        <version>2.10</version> </extension> </extensions> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactid>wagon-maven  
                -plugin</artifactid> <version>1.0</version> <configuration> <serverId>webserver</serverId> <!--files to deploy-<fromfile >target/osc-shop.war</fromFile> <!--deployment Directory-<url>scp://hadoop@1  
        92.168.1.222/home/hadoop/apache-tomcat-8.0.5/webapps/</url> <commands>            <!--off Tomcat--<command>/home/hadoop/apache-tomcat-8.0.5/bin/shutdown.sh& lt;/command> <!--Remove the previously unpacked directory--<command>rm-rf/home/hadoop/a  
                    Pache-tomcat-8.0.5/webapps/osc-shop </command> <!--start Tomcat-- <command>/home/hadoop/apache-tomcat-8.0.5/bin/startup.sh</command> < /commands> <displayCommandOutputs>true</displayCommandOutputs> </configu  ration> </plugin> </plugins> </build>

After the configuration is complete, execute the command
MVN clean package wagon:upload-single wagon:sshexec
to deploy to the server and reboot 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.