我们习惯于使用 maven ant 任务将我们的工件发送到我们的服务器,但现在这不再起作用了......我不知道发生了什么变化,当 maven 运行任务时,我们得到这个异常
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (scp-to-remote) on project quipark: An Ant BuildException has occured: com.jcraft.jsch.JSchException: Auth fail
[ERROR] around Ant part ...<scp trust="true" password="password" localFile="path_to_jar" remoteToFile="admin@192.168.3.240:/Users/admin/Public/dir" verbose="true"></scp>... @ 4:204 in /Users/admin/sviluppo/workspace/app/target/antrun/build-main.xml
如果我们使用钥匙孔选项而不是密码,它也不起作用。这很奇怪,因为我们可以使用相同的凭据毫无问题地进入服务器
这是插件的POM部分
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>scp-to-remote</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<scp localFile="${project.basedir}/target/app.jar"
remoteToFile="${remoteToFile}"
verbose="true" password="${password}" trust="true">
</scp>
</target>
</configuration>
</execution>
</executions>
<!-- libraries for scp impl -->
<!-- antrun doesn't use os's scp -->
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
</plugin>
${remoteToFile}
取自我的Maven设置,就像admin@192.168.3.240:/Users/admin/Public/dir
这是异常的完整堆栈跟踪
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (scp-to-remote) on project quipark: An Ant BuildException has occured: com.jcraft.jsch.JSchException: Auth fail
[ERROR] around Ant part ...<scp trust="true" password="password" localFile="path_to_jar" remoteToFile="admin@192.168.3.240:/Users/admin/Public/dir" verbose="true"></scp>... @ 4:202 in /Users/mario/GoogleDrive/sviluppo/workspace/quipark/target/antrun/build-main.xml
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (scp-to-remote) on project quipark: An Ant BuildException has occured: com.jcraft.jsch.JSchException: Auth fail
around Ant part ...<scp trust="true" password="password" localFile="path_to_jar" remoteToFile="admin@192.168.3.240:/Users/admin/Public/dir" verbose="true"></scp>... @ 4:202 in /Users/mario/GoogleDrive/sviluppo/workspace/quipark/target/antrun/build-main.xml
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: com.jcraft.jsch.JSchException: Auth fail
around Ant part ...<scp trust="true" password="password" localFile="path_to_jar" remoteToFile="admin@192.168.3.240:/Users/admin/Public/dir" verbose="true"></scp>... @ 4:202 in /Users/mario/GoogleDrive/sviluppo/workspace/quipark/target/antrun/build-main.xml
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:342)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: /Users/mario/GoogleDrive/sviluppo/workspace/quipark/target/antrun/build-main.xml:4: com.jcraft.jsch.JSchException: Auth fail
at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:187)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:313)
... 22 more
Caused by: com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:512)
at com.jcraft.jsch.Session.connect(Session.java:183)
at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:180)
at org.apache.tools.ant.taskdefs.optional.ssh.Scp.upload(Scp.java:249)
at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:176)
... 34 more
我相信您的 scp 任务中缺少用户名="xxxxx"