Question

I'm new to jenkins and phing and having what appears to be a basic error with jenkins not being able to run my phing commands. Console log of my failed build is below. I only have one install of phing so I understand I don't need to "configure the job to choose one", I've also tried to add a PATH to my jenkins global environment variables and restarted Jenkins after adding the variables and still no go. I already have Phing in my local PATH as I can invoke the phing command anywhere. I'm also able to invoke the same phing command that jenkins does from terminal and the the build finishes. However, Jenkins' Build Now always fails. Any help would be great! thanks :)

Started by user anonymous

Building in workspace /Users/Shared/Jenkins/Home/jobs/php-template/workspace

Fetching changes from the remote Git repository

Fetching upstream changes from ssh://git@mystash.server:7999/myproject/myrepo.git

Checking out Revision 8fb6f843d6fd232cdde1684e18c455cef6f20460 (origin/master)
looking for '/Users/Shared/Jenkins/Home/jobs/php-template/workspace/build.xml' ... 

use '/Users/Shared/Jenkins/Home/jobs/php-template/workspace' as a working directory. 

[workspace]    
$ phing -buildfile /Users/Shared/Jenkins/Home/jobs/php-template/workspace/build.xml clean try_ParallelTasks -logger phing.listener.DefaultLogger

FATAL: command execution failed.Maybe you need to configure the job to choose one of your Phing installations?
java.io.IOException: Cannot run program "phing" (in directory "/Users/Shared/Jenkins/Home/jobs/php-template/workspace"): error=2, No such file or directory

    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:773)
    at hudson.Launcher$ProcStarter.start(Launcher.java:353)
    at hudson.Launcher$ProcStarter.join(Launcher.java:360)
    at hudson.plugins.phing.PhingBuilder.perform(PhingBuilder.java:215)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
    at hudson.model.Build$BuildExecution.build(Build.java:199)
    at hudson.model.Build$BuildExecution.doRun(Build.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:585)
    at hudson.model.Run.execute(Run.java:1670)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:231)
        Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
    at java.lang.ProcessImpl.start(ProcessImpl.java:130)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
    ... 15 more
Build step 'Invoke Phing targets' marked build as failure

No correct solution

OTHER TIPS

To be clearer, as Cweiske pointed out, Jenkins fails the build because it cannot find the correct phing executable, as it looks for it in the wrong path (the one in the workspace).

Anyway, Jenkins search for that executable in other paths too, as the one you cited: "in my local PATH as I can invoke the phing command anywhere".

The problem with Your Local Path is that it is the YOUR and not the Jenkin's one. As Jenkins act on your Mac with its own user (jenkins, created during the installation process), so it cannot use Your Local Path.

Understood the problem, there is more than one possible solution (and i've tried them one by one with no success!), but the simpler (and the one that finally works!) is the "symlinking".

A note: please, take care of the difference between various types of "links" on Mac: SymLinks are different and not equals to Aliases or to Hard Links (http://macs.about.com/od/faq1/f/What-Are-Aliases-Symbolic-Links-And-Hard-Links-In-Mac-Os-X.htm).

Coming back, as in the usr/bin folder there are executables that each user on the mac can use, let's create a symlink into this folder to the executable you use every time, the one included in the folder in Your Local Path.

From Terminal, go to the usr/bin folder. Use the command "cd" to change the current directory and to go to the top of the root use something like:

> cd ../

With the command "pwd" you can see the complete path to the directory in which you currently are, and with the "ls" command you can list all the files and folders in it: use them to guide yourself in the folders tree.

So, assuming you already are in the usr/bin folder and assuming you are using MAMP as webserver, the command is:

> ln /Applications/MAMP/bin/php/php5.5.10/bin/phing ./phing

As you can see, the first parameter is the path to the executable you want to symlink, and the second parameter is the path to the folder in which you want to create the symlink. Don't forget to append the name of your new symlink!

Once done, try again to build with Jenkins: all should work well now... i hope!

Some troubleshooting:

1) You created the symlink in the wrong folder: use "rm" to remove a file

2) You haven't the right permissions: use "sudo" to act as a super admin

> sudo ln /Applications/MAMP/bin/php/php5.5.10/bin/phing ./phing

The directory in which the phing script is installed is not in $PATH of the jenkins user.

Symlink it into /usr/bin/, and you should be set.

From the following error message

Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:248) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

I got this "IOException when starting a process"

It seems like ProcessBuilder doesn't use the env variable PATH, so it can't find find phing

What I did is I removed Invoke Phing targets and added the Build as Execute Shell, and in Command I added /usr/local/bin/phing. and that is working for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top