maven antrun ssh或scp隐藏输出
我想在mvn中使用antrun运行ssh和scp命令。maven antrun ssh或scp隐藏输出,maven,ssh,ant,scp,Maven,Ssh,Ant,Scp,我想在mvn中使用antrun运行ssh和scp命令。 ssh&scp命令正确运行,并且在下一阶段中声明的插件运行正常。 但是ssh/scp之后的所有命令的输出都不会写入任何输出 有什么问题 以下是我的pom.xml: <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSche
ssh&scp命令正确运行,并且在下一阶段中声明的插件运行正常。 但是ssh/scp之后的所有命令的输出都不会写入任何输出 有什么问题 以下是我的pom.xml:
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>0.0.0-1-SNAPSHOT</version>
<name>name</name>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>echoKuku</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<sshexec verbose="true" output="o.txt" failonerror="false" host="${Ip}" trust="yes"
username="${UserName}" command="echo kuku" keyfile="${Keyfile}" />
<taskdef name="sshexec" classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
classpathref="maven.plugin.classpath" />
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.1.29</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>download-jsch</id>
<phase>compile</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<overWriteSnapshots>true</overWriteSnapshots>
<artifactItems>
<artifactItem>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.1.29</version>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<javaVersion>1.7</javaVersion>
<Ip>1.2.3.4</Ip>
<UserName>root</UserName>
<Keyfile>${user.home}/.ssh/id_rsa</Keyfile>
</properties>
<dependencies>
<dependency>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.1.29</version>
</dependency>
</dependencies>
</project>
更新:(16/3/16 8:11 GMT)
scp-工作正常。带有文件脚本的sshexec(commandResource=“[file]”)-工作正常。
sshexec只使用一个命令(command=“[command]”)-如上所述,会导致问题。尝试使用较新版本的JSCH依赖项(ant JSCH为1.8.4,JSCH为0.1.53,每个版本都有不同的组ID)。它解决了我这边的问题:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>server-copy</id>
<goals>
<goal>run</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<target>
<echo message="Pushing to host..." />
<sshexec host="hostname" username="user" trust="true"
password="pass" failonerror="true"
command="mkdir -p /home/user/test/test"/>
<scp trust="yes"
file="some-file"
todir="user:pass@hostname:/path/to/some-file"
/>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
</dependencies>
</plugin>
org.apache.maven.plugins
maven antrun插件
服务器副本
跑
过程源
org.apache.ant
ant jsch
1.8.4
com.jcraft
jsch
0.1.53
尝试使用较新版本的JSCH依赖项(ant JSCH为1.8.4,JSCH为0.1.53,每个版本都有不同的组ID)。它解决了我这边的问题:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>server-copy</id>
<goals>
<goal>run</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<target>
<echo message="Pushing to host..." />
<sshexec host="hostname" username="user" trust="true"
password="pass" failonerror="true"
command="mkdir -p /home/user/test/test"/>
<scp trust="yes"
file="some-file"
todir="user:pass@hostname:/path/to/some-file"
/>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
</dependencies>
</plugin>
org.apache.maven.plugins
maven antrun插件
服务器副本
跑
过程源
org.apache.ant
ant jsch
1.8.4
com.jcraft
jsch
0.1.53
非常感谢。经过两个漫长的夜晚,我找到了解决办法
我有最新版本的ant,而不是org.apache.ant,它在版本1.6中被更改
所以最新版本是今天的1.10.1,它运行得非常好。非常感谢。经过两个漫长的夜晚,我找到了解决办法 我有最新版本的ant,而不是org.apache.ant,它在版本1.6中被更改
所以最新版本是今天的1.10.1,它运行得非常好。您尝试过这个吗:当然。这就是我使用的插件!你试过这个吗:当然。这就是我使用的插件!谢谢你提到这件事。另一条评论有它,但我有点掩盖了其中的片段,因为上面提到了版本。这条评论直接指出了这一变化。谢谢你提到这一点。另一条评论有它,但我有点掩盖了其中的片段,因为上面提到了版本。这一评论直接引发了这一变化。