Pregunta

I configure my job as freestyle. And I need to run cases to a specified machine. MY project is maven project. I want to copy reports to master node after cases finish to run.

Jenkins ver. 1.483

I use pscp to copy files which works fine by hand in windows command prompt. My command looks like:

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%

The pscp seems not work. When I use command like this:

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

EchoCommand is working again.===Not show at the output of the console while EchoCommand is working.=== has been shown. Why? Anyone knows that?

EDIT

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
¿Fue útil?

Solución

mvn is a batch file. So It is need to call mvn .... Not just mvn ....

See call-batch-file-from-cygwin-breaks-after-1st-command

Otros consejos

This could be due to an environment problem. You could, however, save yourself a lot of time and work by doing things a little bit different:

  • Make your job a Maven Project, makes configuration easier (and offers you nice features like test reports for single modules etc.). This might also make your report copying unneccessary.

  • Depending on what you want to do with these reports afterwards, you could simple use the Jenkins archiving mechanism to copy them over to your master.

  • if you REALLY need to copy them by hand, use the Publish Over SSH Jenkinsn plugin

Are you using Execute Shell in your free-style project, i.e. you are running on a *nix based environment? If so, your problem is detailed in my answer here:
Jenkins Build Script exits after Google Test execution

Jenkins launches Execute Shell as a temporary shell script with command /bin/sh -xe tempshell.sh. Note the -e part. This tells sh to exit when any single command in the script returns with non-zero value.

Your mvn clean install -U is probably returning with a non-zero value. You can check that by running it on command line, immediately followed by echo $?

Solution: To circumvent that, add set +e to the top of your Execute Shell script.

The problem may be that you are not giving enter after the last command.

Today I came across the same problem in our project, last command in jenkins is not executed.

After some trail and error methods, came to understand that.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top