maven - Jenkins 不执行 mvn 命令后的最后一个命令

标签 maven jenkins continuous-integration automated-tests

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

Jenkins 版本。 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 再次工作。===EchoCommand 工作时,控制台的输出不显示。=== 已显示。为什么?有人知道吗?

编辑

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

最佳答案

mvn 是批处理文件。所以需要调用mvn .... 不仅仅是mvn ....

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

关于maven - Jenkins 不执行 mvn 命令后的最后一个命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22856002/

相关文章:

java - 向 Maven <finalname> 添加一个自动递增的数字

java - Intellij 无法识别 pom.xml 中的环境变量

java - Maven - 即使依赖路径正确,编译也会出错

msbuild - 来自 TeamCity 的 MSBuild 的/P MSDeploy 参数的完整列表

postgresql - GitLab CI : How to setup postgres image using GitLab secure variables

java - 如何处理打包到jar的maven项目中的资源路径

android - 使用 Jenkins 构建 android 项目 :Could not initialize analytics

jenkins - 在Jenkins中调试Groovy脚本化管道

maven - Jenkins pipeline、bitbucket hook 和 maven 发布插件无限循环

python - 检测代码何时在 Travis CI 上运行