I have a Jenkins server running on Ubuntu; sources are on Plastic and I already have a Windows slave making Android builds, so the Plastic server is well responding with Jenkins.
I try to build the project for IOS on Mac but the job fails when getting the sources with a java exception
java.io.IOException: error=2, No such file or directory
I tried to remove the source control for the job and just running some commands like :
cm status
It failed, so I updated the PATH environment variable to make it work. Now it's ok for manual commands but still not for the automatic plastic pull.
I configured the job to pull from it using the PlasticSCM Plugin using the selector :
repository "MyRepo"
path "/"
smartbranch "/My/Branch"
Here is the complete error :
[test-mac] $ cm find changeset where date between '2019-05-27T11:14:36' and '2019-05-27T11:15:43' and branch='/My/Branch' on repositories 'MyRepo' --xml --dateformat=yyyy'-'MM'-'dd'T'HH':'mm':'ss
java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 192.168.1.46/192.168.1.46:49336
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
at hudson.remoting.Channel.call(Channel.java:957)
at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1059)
at hudson.Launcher$ProcStarter.start(Launcher.java:455)
at com.codicesoftware.plugins.hudson.PlasticTool.tryExecute(PlasticTool.java:97)
at com.codicesoftware.plugins.hudson.PlasticTool.execute(PlasticTool.java:57)
at com.codicesoftware.plugins.hudson.commands.CommandRunner.execute(CommandRunner.java:20)
at com.codicesoftware.plugins.hudson.commands.CommandRunner.executeAndRead(CommandRunner.java:36)
at com.codicesoftware.plugins.hudson.commands.CommandRunner.executeAndRead(CommandRunner.java:25)
at com.codicesoftware.plugins.hudson.commands.ChangesetsRetriever.getChangesets(ChangesetsRetriever.java:27)
at com.codicesoftware.plugins.hudson.commands.ChangesetsRetriever.getDetailedHistory(ChangesetsRetriever.java:36)
at com.codicesoftware.plugins.hudson.PlasticSCM.FindCsets(PlasticSCM.java:363)
at com.codicesoftware.plugins.hudson.PlasticSCM.SetUpWorkspace(PlasticSCM.java:175)
at com.codicesoftware.plugins.hudson.PlasticSCM.checkout(PlasticSCM.java:141)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1816)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused: java.io.IOException: Cannot run program "cm" (in directory "/Users/MyUser/Jenkins/workspace/test-mac"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:249)
at hudson.Proc$LocalProc.<init>(Proc.java:218)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
at hudson.Launcher$ProcStarter.start(Launcher.java:455)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1313)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1266)
at hudson.remoting.UserRequest.perform(UserRequest.java:212)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
at java.lang.Thread.run(Thread.java:748)
I think the problem could be related to the following Jenkins bug: https://issues.jenkins-ci.org/browse/JENKINS-17157 (Enviroment variables are not loaded in ssh using cygwin)
If your slave is connecting via SSH to your Jenkins server, the environment variables are lost so you can't run "cm" commands. The following link may be useful: (https://support.cloudbees.com/hc/en-us/articles/229724088-How-to-set-up-a-Jenkins-agent-to-have-the-same-path-as-the-user-when-connected-via-Remote-Desktop-)
In the past, we tried to connect the slave via "Java Web Start" (not via SSH) and we were not able to reproduce this issue with the lost PATH variable (it's only happening when connecting via SSH).
On the macOS: - Running: eg:
sudo java -jar agent.jar -jnlpUrl http://MySERVER84/computer/macOsJava/slave-agent.jnlp -secret f5dcf86e0ceed3f22c08bc27fa07d680aff3e11c25452677af4fee218bcfb1aa -workDir "/tmp"