当前位置 : 主页 > 网络编程 > net编程 >

73-wagon-ssh远程上传jar等文件并部署

来源:互联网 收集:自由互联 发布时间:2023-09-06
属性值: properties ssh.ip192.168.207.109/ssh.ip ssh.usernameroot/ssh.username ssh.pwd1q2w3e4r5t/ssh.pwd ssh.run.skipfalse/ssh.run.skip ssh.lib.skiptrue/ssh.lib.skip ssh.yml.skiptrue/ssh.yml.skip ssh.exec.skipfalse/ssh.exec.skip/propert

属性值:

<properties>
        <ssh.ip>192.168.207.109</ssh.ip>
        <ssh.username>root</ssh.username>
        <ssh.pwd>1q2w3e4r5t</ssh.pwd>
        <ssh.run.skip>false</ssh.run.skip>
        <ssh.lib.skip>true</ssh.lib.skip>
        <ssh.yml.skip>true</ssh.yml.skip>
        <ssh.exec.skip>false</ssh.exec.skip>
</properties>

添加扩展依赖包:

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

添加插件plugin:

<plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>wagon-maven-plugin</artifactId>
                    <version>2.0.2</version>

                    <configuration>
                        <settings>
                            <servers>
                                <server>
                                    <id>wagon-ssh</id>
                                    <username>${ssh.username}</username>
                                    <password>${ssh.pwd}</password>
                                </server>
                            </servers>
                        </settings>
                        <serverId>wagon-ssh</serverId>
                        <url>scp://${ssh.ip}</url>
                        <skip>false</skip>
                    </configuration>
                    <executions>
                        <execution>
                            <id>ssh-upload-yml</id>
                            <phase>package</phase>
                            <goals>
                                <goal>upload</goal>
                            </goals>
                            <configuration>
                                <skip>${ssh.yml.skip}</skip>
                                <fromDir>target/classes</fromDir>
                                <toDir>${ssh.path}</toDir>
                                <includes>*.yml</includes>
                            </configuration>
                        </execution>
                        <execution>
                            <id>ssh-upload-lib</id>
                            <phase>package</phase>
                            <goals>
                                <goal>upload</goal>
                            </goals>
                            <configuration>
                                <skip>${ssh.lib.skip}</skip>
                                <fromDir>target</fromDir>
                                <toDir>${ssh.path}</toDir>
                                <includes>lib/*</includes>
                            </configuration>
                        </execution>
                        <execution>
                            <id>ssh-upload-run</id>
                            <phase>package</phase>
                            <goals>
                                <goal>upload</goal>
                            </goals>
                            <configuration>
                                <skip>${ssh.run.skip}</skip>
                                <fromDir>target</fromDir>
                                <toDir>${ssh.path}</toDir>
                                <includes>${project.build.finalName}.jar</includes>
                            </configuration>
                        </execution>
                        <execution>
                            <id>ssh-exec</id>
                            <phase>package</phase>
                            <goals>
                                <goal>sshexec</goal>
                            </goals>
                            <configuration>
                                <skip>${ssh.exec.skip}</skip>
                                <displayCommandOutputs>true</displayCommandOutputs>
                                <commands>
                                    <command>mv ${ssh.path}/${project.build.finalName}.jar ${ssh.path}/run.jar</command>
                                </commands>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
网友评论