v5tech / notes

notes
https://ameizi.gitee.io/notes
MIT License
1.52k stars 378 forks source link

java自动化部署插件 #186

Open v5tech opened 5 years ago

v5tech commented 5 years ago

在maven的pom.xml中添加如下配置:

<extensions>
    <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ssh</artifactId>
        <version>2.8</version>
    </extension>
</extensions>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>wagon-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <id>upload-deploy</id>
                    <phase>package</phase>
                    <goals>
                        <goal>upload-single</goal>
                        <goal>sshexec</goal>
                    </goals>
                    <configuration>
                        <fromFile>target/joyplus-manage-2.0.jar</fromFile>
                        <url>scp://root:***@106.214.240.250/opt</url>
                        <commands>
                            <command><![CDATA[ chmod +x /opt/joyplus-manage-2.0.jar ]]></command>
                            <command><![CDATA[ sh /opt/upgrade-joyplus-manager.sh ]]></command>
                        </commands>
                        <displayCommandOutputs>true</displayCommandOutputs>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>