我的情景: 我已将某些测试文件部署到服务器上,并且我想使用maven在该远程服务器上运行shell脚本。没有maven插件,因为我这样做。 shell脚本将运行测试并以.txt格式生成输出。
我的问题: 我已经使用maven-ant-run插件成功运行了脚本但是它没有显示maven输出。执行脚本后,运行maven时的输出后面没有显示任何内容。所以在这种情况下,使用maven-ant-run并不理想。这是我的POM.xml的一部分:
<plugin>
<!-- Step to copy the unit tests to designated destination -->
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>Deploy Unit tests onto Server</id>
<phase>process-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Copy files to the remote integration test server -->
<!-- Transferring unit tests -->
<scp failonerror="true" todir="${scp.user}:${scp.password}@${scp.host}:/${scp.dirCopyToUnit}" trust="true">
<fileset dir="${scp.UnitTest.api.dir}">
<include name="*"></include>
</fileset>
</scp>
<!-- transferring resources files -->
<scp failonerror="true" todir="${scp.user}:${scp.password}@${scp.host}:/${scp.dirCopyToUnitResources}" trust="true">
<fileset dir="${scp.UnitTest.api.dirResources}">
<include name="*"></include>
</fileset>
</scp>
<!-- transferring spec_helper.lua -->
<scp failonerror="true" todir="${scp.user}:${scp.password}@${scp.host}:/${scp.dirCopySpec_Helpers}" trust="true">
<fileset dir="${scp.UnitTest.api.dirSpec_Helpers}">
<include name="*"></include>
</fileset>
</scp>
<sshexec command="sh /tmp/unitTestMaven.sh exit exit" host="${scp.host}" password="${scp.password}" trust="yes" username="${scp.user}"></sshexec>
<taskdef classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec" classpathref="maven.plugin.classpath" name="sshexec"></taskdef>
</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.8.4</version>
</dependency>
</dependencies>
</plugin>
有人可以对此有所了解吗?
可能的资源:maven antrun ssh or scp hides the output
我也尝试过使用旅行车插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>execute-test-commands</id>
<phase>test</phase>
<goals>
<goal>sshexec</goal>
</goals>
<configuration>
<serverId>atlassian-public</serverId>
<url>"scp://${scp.user}:${scp.password}@${scp.host}"</url>
<commands>
<command>sh /tmp/unitTestMaven.sh</command>
</commands>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
但是收到以下错误:org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0:sshexec (execute-test-commands) on project aa: Unable to create a Wagon instance