问题
In my build.xml
I defined some jobs, that should be executed by tools, I installed globally via Composer. That means, the binaries are stored in /root/.composer/vendor/bin/
(I'm working as root
on my local VM).
I set the PATH
environment variable in the composer configs (without it the build process was failing):

Now the building process is running in permission issues:
Started by user anonymous
Running as anonymous
Building in workspace /path/to/myproject
[myproject] $ ant
Buildfile: /path/to/myproject/build.xml
phpcs:
BUILD FAILED
/path/to/myproject/build.xml:30: Execute failed: java.io.IOException: Cannot run program "phpcs": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
...
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 24 more
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
The binaries in COMPOSER_HOME/bin
are executable for everyone:
root@ubuntuvm:~# chmod 777 /root/.composer/vendor/bin/
root@ubuntuvm:~# ls -lia /root/.composer/vendor/bin/
total 8
...
29651 lrwxrwxrwx 1 root root 42 Feb 17 14:49 phpcs -> ../squizlabs/php_codesniffer/scripts/phpcs
...
I've installed the Authorize Project plugin and tried to run the build "as the user who triggered the build", but it didn't help.

But that seems not to be enough.
How to give resolve these permissions problems and get Jenkins working with binaries of global
ly installed Composer packages?
回答1:
The executable is not an executable file, but a symlink to another file, and THOSE permissions need to be correct. Did you check that?
回答2:
It seem to be impossible to execute (Composer) binaries stored in a sub-folder of another (root
) user from/by Jenkins.
A workaround, that works for me, is to move the COMPOSER_HOME
to a folder, Jenkins has access to, e.g.:
$ mv /root/.composer /usr/share/.composer
$ nano /etc/environment
...
PATH=...
COMPOSER_HOME="/usr/share/.composer"
...
$ nano ~/.profile
...
export PATH=$PATH:$COMPOSER_HOME/vendor/bin
...
The PATH
environment variables needs to be set then in the Jenkins configuration (Manage Jenkins -> Configure System -> Global properties -> Environment variables
) to $PATH:$COMPOSER_HOME/vendor/bin/
:

来源:https://stackoverflow.com/questions/36463110/how-to-get-jenkins-working-with-binaries-from-a-subfolder-of-the-root-user