2
votes

I've been scratching my head on this issue but haven't found a way around it. I've installed Jenkins on my OSX v10.8.4 using the Jenkins 1.571 installer from the Jenkins website. It gets installed by default in /Users/Shared/Jenkins/Home folder.

I want to use Jenkins to act as a CI server for my iOS code residing on my company's perforce server. For this I created a user(matching to that of my perforce user along with the same password)on my OSX box. I also copied the P4 command line to /usr/local/bin and correctly setup the P4PORT to point to my perforce server settings. So far so good.

I verified that I was able to connect to my perforce server from command line by using the p4 login command, and it worked successfully.

I then installed the perforce plugin from Jenkins Manage plugins option (https://wiki.jenkins-ci.org/display/JENKINS/Perforce+Plugin). Now when I create a new job and specify the settings correctly in the perforce plugin piece of the jenkins job, I always get these errors:

   Started by user anonymous
   Building in workspace /Users/Shared/Jenkins/Home/jobs/iosbuild/workspace
   Using master perforce client: ios-jenkins
   [workspace] $ p4 workspace -o ios-jenkins
   Caught exception communicating with perforce. Could not run perforce           command.com.tek42.perforce.PerforceException: Could not run perforce command.
    at hudson.plugins.perforce.HudsonP4DefaultExecutor.exec(HudsonP4DefaultExecutor.java:90)
    at             com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:331)
    at     com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:301)
    at com.tek42.perforce.parse.Workspaces.getWorkspace(Workspaces.java:61)
    at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1615)
    at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1576)
    at hudson.plugins.perforce.PerforceSCM.checkout(PerforceSCM.java:892)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
    at     hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
    at hudson.model.Run.execute(Run.java:1732)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:234)
    Caused by: java.io.IOException: Cannot run program "p4" (in directory    "/Users/Shared/Jenkins/Home/jobs/iosbuild/workspace"): error=2, No such file or directory
    at java.lang.ProcessBuilder.processException(ProcessBuilder.java:478)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:457)
    at hudson.Proc$LocalProc.(Proc.java:244)
    at hudson.Proc$LocalProc.(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:780)
    at hudson.Launcher$ProcStarter.start(Launcher.java:360)
    at hudson.plugins.perforce.HudsonP4DefaultExecutor.exec(HudsonP4DefaultExecutor.java:81)
    ... 14 more
    Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.(UNIXProcess.java:53)
    at java.lang.ProcessImpl.start(ProcessImpl.java:91)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
    ... 19 more
    ERROR: Unable to communicate with perforce. Could not run perforce command.
    Finished: FAILURE`

First I specified the perforce jenkins plugin to create the workspace for me and also let jenkins to manage my views, but I still got the same above error. Following is my view map:

//depot/rombay/MarketingApplication/iOS/ianywhere/... //ios-jenkins/depot/rombay/MarketingApplication/iOS/anywhere/...

I then created a workspace using the p4v client, and then deselected letting jenkins create my workspaces and manage my views. The view map remains the same. However, I still get the same error.

My hunch is that since Jenkins is installed in the shared folder it's not able to execute the p4 command. However, I tried doing that and it opened up the clientspec in vi for me, which is I guess the expected behavior, but I still don't understand as to why it says that it can't find the p4 program to work for me.

Any help here would be deeply appreciated as I've run out of ideas as to what could possibly be I doing wrong.

1
Did you either give Jenkins the full path to p4 or is p4 in the path that the user account that Jenkins is running under uses? It looks like it's complaining that it can't find the p4 executable. - Timo Geusch
Thanks for the info, Timo. I had to copy my P4 executable manually to /usr/local/bin/p4 and I've specified its path in the configure section of adding perforce installation by providing its path to /usr/local/bin/p4, even though the title of the field says p4.exe, but I still provided the path to the executable for OSX - ash1977
I figured out the issue, jenkins was looking inside /usr/bin folder where as I had copied it under /usr/local/bin folder. creating a symbolic link fixed the issue. Now I realize what a stupid problem I was spending time on. I'm glad it works. Thanks Timo for pointing me to the right direction. - ash1977
Note that this may break again if/when you update the build machine to OS X El Capitan, due to rootless protection. If rootless is enabled, you are not able to make changes to /usr/bin and your customizations may be removed during the upgrade. More info: apple.stackexchange.com/questions/193368/… - Br.Bill

1 Answers

0
votes

No softlinks are required. Check if you have updated the Global Settings for p4. Manage Jenkins->Global Settings