Pipeline Maven: Running on Windows slave

922 views
Skip to first unread message

Sverre Moe

unread,
Sep 11, 2017, 2:07:21 AM9/11/17
to Jenkins Users
I have connected a Windows slave to Jenkins with SSH+Cygwin.
So running shell scripts like "sh 'mvn'" should work as I do it locally on the Windows.

Running withMaven fails, and I cannot figure our why.

[Pipeline] node
Running on master-windows-x86_64 in /home/username/workspace/myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout-Windows)
[Pipeline] checkout
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url ssh://g...@git.company.com/software/myApp.git # timeout=10
Fetching without tags
Fetching upstream changes from ssh://g...@git.company.com/software/myApp.git
 > git --version # timeout=10
 > git fetch --no-tags --progress ssh://g...@git.company.com/software/myApp.git +refs/heads/*:refs/remotes/origin/*
Checking out Revision 05cf171deb903a01b5880c30de28d4b1865e3ed5 (username/work)
Commit message: "Test Windows build on Jenkins"
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 05cf171deb903a01b5880c30de28d4b1865e3ed5
 > git rev-list f9db8914f5688ca74e571dd1104c279f207bf435 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build-Windows)
[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options: 
[withMaven] use JDK installation jdk1.8
$ where mvn.cmd
[withMaven] use Maven installation provided by the build agent with executable C:\Users\username.POLAR\Downloads\apache-maven-3.3.9-bin\apache-maven-3.3.9\bin\mvn.cmd
[Pipeline] {
[Pipeline] sh
[myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ] Running shell script
sh: /home/username/workspace/myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ@tmp/durable-ff9c24b3/pid: No such file or directory
sh: /home/username/workspace/myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ@tmp/durable-ff9c24b3/jenkins-log.txt: No such file or directory
sh: /home/username/workspace/myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ@tmp/durable-ff9c24b3/jenkins-result.txt: No such file or directory


Sverre Moe

unread,
Sep 11, 2017, 2:18:38 AM9/11/17
to Jenkins Users
I took a look at the Maven Pipeline documentation again.
For Windows it says to use bat, not sh. I tried that, and got a little bit closer, but now it cannot find JAVA_HOME
----- withMaven Wrapper script -----

Error: JAVA_HOME is set to an invalid directory.
JAVA_HOME
= "/usr/java/jdk1.8.0_102"
Please set the JAVA_HOME variable in your environment to match the
location of your
Java installation.

Jenkins have jdk set at /usr/java/jdk1.8.0_102 and I have created a symlink in my Cygwin
jdk1.8.0_102 -> /cygdrive/c/Program Files/Java/jdk1.8.0_121
Windows environment variable JAVA_HOME is set to C:\Program Files\Java\jdk1.8.0_121

Sverre Moe

unread,
Sep 11, 2017, 2:35:29 AM9/11/17
to Jenkins Users
Well, adding a new JDK in Jenkins Tools pointing to the Windows path of Java worked
Then withMaven(jdk: "jdk1.8-win")

I have though hit another snag. Lots of ERROR after build success.
ERROR: [withMaven] WARNING: Exception archiving and fingerprinting MavenArtifact{no.spacetec:myApp:jar:1.0.0-SNAPSHOT C:\home\username\workspace\myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ\target\myApp-1.0.0-SNAPSHOT.jar}, skip archiving of the artifacts

ERROR: [withMaven] WARNING: Exception archiving and fingerprinting MavenArtifact{no.spacetec:myApp:rpm:1.0.0-SNAPSHOT C:\home\username\workspace\myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ\target\rpm\myApp-windows-installer\RPMS\noarch\myApp-windows-installer-1.0.0-SNAPSHOT20170911082120.noarch.rpm}, skip archiving of the artifacts

ERROR: [withMaven] WARNING Exception executing Maven reporter 'Junit Publisher' / org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org 
java.lang.IllegalArgumentException: Cannot relativize 'C:\home\username\workspace\myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ\target/surefire-reports' relatively to '/home/username/workspace/myApp_username_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ'
at org.jenkinsci.plugins.pipeline.maven.util.XmlUtils.getPathInWorkspace(XmlUtils.java:226)
at org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher.executeReporter(JunitTestsPublisher.java:234)
at org.jenkinsci.plugins.pipeline.maven.publishers.JunitTestsPublisher.process(JunitTestsPublisher.java:181)
at org.jenkinsci.plugins.pipeline.maven.MavenSpyLogProcessor.processMavenSpyLogs(MavenSpyLogProcessor.java:109)
at org.jenkinsci.plugins.pipeline.maven.WithMavenStepExecution$Callback.finished(WithMavenStepExecution.java:864)
at org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback$TailCall.onSuccess(BodyExecutionCallback.java:114)
at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.receive(CpsBodyExecution.java:362)
at com.cloudbees.groovy.cps.Outcome.resumeFrom(Outcome.java:73)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:165)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

ERROR: [withMaven] WARNING Exception executing Maven reporter 'Open Task Scanner Publisher' / org.jenkinsci.plugins.pipeline.maven.publishers.TasksScannerPublisher. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org 

It would seem it is unable to use the "correct" home directory as Windows is using Cygwin.

Sverre Moe

unread,
Sep 11, 2017, 3:03:36 AM9/11/17
to Jenkins Users
The fix was to set the Windows slave Remote Root Directory to Windows URI
C:\cygwin64\home\username

Baptiste Mathus

unread,
Sep 11, 2017, 3:08:53 AM9/11/17
to jenkins...@googlegroups.com
Hello,
I know the developers of that plugin would like to make it as good as possible. To that, if so, could you please try and summarize what you think could be made easier/better? And even if possibly a config error, if you think the error could help more quickly understand what is wrong?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5da9746b-17c9-47b7-ab1e-88f32b0416f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cyrille Le Clerc

unread,
Sep 12, 2017, 4:51:46 AM9/12/17
to Jenkins Users
Hello Svere,

It seems that we have some work to make withMaven(){} more friendly to Windows+Cygwin users.

We have already tracked:
Some refactoring of the code will be needed to generate both standard Windows and Cygwin friendly scripts on Windows agents.

Please feel free to give us hints on what a smooth integration with Windows and Cygwin should look like.

Cyrille
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Sverre Moe

unread,
Oct 4, 2017, 7:36:19 AM10/4/17
to Jenkins Users
Here follows an update of some observations and configurations I have done to get building on Windows to work.

The Windows node is connected in Jenkins with SSH started by sshd in Cygwin.

The Windows node's "Remote root directory" is set to "C:\cygwin64\home\build", because "/home/build" would not work.
Step withMaven woulld fail with use of the latter:
[myApp_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ] Running shell script
sh
: /home/build/workspace/myApp_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ@tmp/durable-e1932da9/pid: No such file or directory
sh
: /home/build/workspace/myApp_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ@tmp/durable-e1932da9/jenkins-log.txt: No such file or directory
sh
: /home/build/workspace/myApp_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ@tmp/durable-e1932da9/jenkins-result.txt: No such file or directory

I have also added an additional Windows JDK in Jenkins pointing to C:\Program Files\Java\jdk1.8.0_144.
Creating a symlink in cygwin at /usr/java/jdk1.8.0_144 to /cygdrive/c/Program\ Files/jdk1.8.0_144 allowed me to use the same Jenkins JDK tool for both Windows and Linux (though only with the sh step).

For the time being I have been using the pipeline step bat after checking !isUnix().
However with the bat step I must use a different JDK that points to the real directory in Windows C:\Program Files\Java\jdk1.8.0_144.
Otherwise withMaven fails to find the JDK at /usr/java/jdk1.8.0_144
[myApp_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ] Running batch script
C:\cygwin64\home\build\workspace\myApp_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ>mvn clean install  
----- withMaven Wrapper script -----
The JAVA_HOME environment variable is not defined correctly 
This environment variable is needed to run this program
NB
: JAVA_HOME should point to a JDK not a JRE


Using the sh step instead of the bat step in pipeline kinda works. However with one Exception.
[withMaven] use Maven installation provided by the build agent with executable C:\Program Files\apache-maven-3.5.0\bin\mvn.cmd
[Pipeline] {
[Pipeline] sh
[C:\cygwin64\home\build\workspace\myApp_sverre_work-3U54DPE57F6TMOZM2O6QBWDQ2LNRU2QHAXT6INC3UPGWF2ERMXAQ] Running shell script
Cannot contact master-windows7-x86_64: java.io.IOException: Remote call on master-windows7-x86_64 failed
+ mvn clean install
The build continues never the less with success, so I am not sure what failed here and what it tried to do on the remote node that caused the IOException.

Reply all
Reply to author
Forward
0 new messages