jenkins在mvn命令后不执行最后一个命令

时间:2014-04-04 07:12:24

标签: maven jenkins continuous-integration automated-tests

我将自己的工作配置为自由式。我需要将案例运行到指定的机器。我的项目是maven项目。我想在完成运行的情况下将报告复制到主节点。

Jenkins ver。 1.483

我使用pscp来复制在Windows命令提示符下手动正常工作的文件。 我的命令如下:

mvn clean install -U
pscp -P 22 -i pgrsa.ppk -r %SLAVE_JENKINS_HOME%\workspace\%JOB_NAME%\target\surefire-reports ci@master:%JENKINS_HOME%/workspace/%JOB_NAME%

pscp似乎不起作用。当我使用这样的命令时:

echo EchoCommand is working.===
mvn clean install -U
echo EchoCommand is working again.===

EchoCommand is working again.===显示EchoCommand is working.===时,未显示在控制台的输出中。为什么?谁知道呢?

修改

C:\Tools\Jenkins\workspace\myproject-testng-sample-windows>echo EchoCommand is working.=== 
EchoCommand is working.===

C:\Tools\Jenkins\workspace\myproject-testng-sample-windows>mvn clean install -U 
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.pak.automation:myproject-testng-sample:jar:1.0.0-SNPASHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing. @ com.pak:pak-parent:2.0.0, C:\Users\pak\.m2\repository\com\pak\pak-parent\2.0.0\pak-parent-2.0.0.pom, line 484, column 12
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-source-plugin is missing. @ com.pak:pak-parent:2.0.0, C:\Users\pak\.m2\repository\com\pak\pak-parent\2.0.0\pak-parent-2.0.0.pom, line 472, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject-testng-sample 1.0.0-SNPASHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://mvn.pak.com/pakrepo/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml
Downloading: http://mvn.pak.com/pak-releases/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml
Downloading: http://mvn.pak.com/pak-snapshots/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml
Downloading: http://mvn.pak.com/third-party/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml


377/377 B   
377/377 B   377/377 B   

Downloaded: http://mvn.pak.com/third-party/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml (377 B at 1.5 KB/sec)

Downloaded: http://mvn.pak.com/pakrepo/org/apache/maven/plugins/maven-source-plugin/maven-metadata.xml (377 B at 1.4 KB/sec)
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myproject-testng-sample ---
[INFO] Deleting C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\target
[INFO] 
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ myproject-testng-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ myproject-testng-sample ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) @ myproject-testng-sample ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ myproject-testng-sample ---
[INFO] Compiling 4 source files to C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myproject-testng-sample ---
[INFO] Surefire report directory: C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@4d20a47e
testMethod1
testMethod2
testMethodmyproject2
testmyprojectSample
testMethod1
testMethod2
testMethodmyproject2
testmyprojectSample
we wont run test with class name: com.pak.myproject.sample.NoInjectionTest
we wont run test with class name: com.pak.myproject.sample.NoInjectionTest
I am test method 2
parameter in test method is: firstname
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.895 sec

Results :

Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ myproject-testng-sample ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\target\myproject-testng-sample-1.0.0-SNPASHOT.jar
[INFO] 
[INFO] >>> maven-source-plugin:2.1.1:jar (attach-sources) @ myproject-testng-sample >>>
[INFO] 
[INFO] <<< maven-source-plugin:2.1.1:jar (attach-sources) @ myproject-testng-sample <<<
[INFO] 
[INFO] --- maven-source-plugin:2.1.1:jar (attach-sources) @ myproject-testng-sample ---
[INFO] No sources in project. Archive not created.
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ myproject-testng-sample ---
[INFO] Installing C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\target\myproject-testng-sample-1.0.0-SNPASHOT.jar to C:\Users\pak\.m2\repository\com\pak\automation\myproject-testng-sample\1.0.0-SNPASHOT\myproject-testng-sample-1.0.0-SNPASHOT.jar
[INFO] Installing C:\Tools\Jenkins\workspace\myproject-testng-sample-windows\pom.xml to C:\Users\pak\.m2\repository\com\pak\automation\myproject-testng-sample\1.0.0-SNPASHOT\myproject-testng-sample-1.0.0-SNPASHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.649 s
[INFO] Finished at: 2014-04-08T13:19:58+08:00
[INFO] Final Memory: 10M/24M
[INFO] ------------------------------------------------------------------------
Recording test results
TestNG Reports Processing: START

4 个答案:

答案 0 :(得分:5)

mvn是一个批处理文件。因此需要call mvn ....而不仅仅是mvn ....

请参阅call-batch-file-from-cygwin-breaks-after-1st-command

答案 1 :(得分:1)

这可能是由于环境问题造成的。但是,你可以通过做一些不同的事情来节省自己的时间和工作:

  • 让您的工作成为Maven项目,使配置更容易(并为您提供很好的功能,如单个模块的测试报告等)。这也可能使您的报告复制不必要。

  • 根据您之后要对这些报告执行的操作,您可以简单地使用Jenkins归档机制将它们复制到主服务器上。

  • 如果您真的需要手动复制它们,请使用Publish Over SSH Jenkinsn plugin

答案 2 :(得分:0)

您是否在自由式项目中使用执行Shell ,即您是在基于* nix的环境中运行的?如果是这样,你的问题在我的答案中有详细说明:
Jenkins Build Script exits after Google Test execution

Jenkins使用命令/bin/sh -xe tempshell.sh作为临时shell脚本启动执行Shell 。请注意-e部分。当脚本中的任何单个命令返回非零值时,这会告诉sh 退出

您的mvn clean install -U可能返回非零值。您可以通过在命令行上运行它来检查,紧接着是echo $?

解决方案:为了避免这种情况,请将set +e添加到执行Shell 脚本的顶部。

答案 3 :(得分:0)

问题可能是您在最后一个命令后没有输入。

今天我在项目中遇到了同样的问题,jenkins的最后一个命令没有执行。

经过一些跟踪和错误的方法后,才明白了。