java自动化部署插件

@ameizi 2018-11-08 08:53:17发表于 ameizi/DevArticles

在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>