如何让 Jenkins 使用 root 用户的子文件夹中的二进制文件? [英] How to get Jenkins working with binaries from a subfolder of the root user?

查看:20
本文介绍了如何让 Jenkins 使用 root 用户的子文件夹中的二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 build.xml 中,我定义了一些应该由工具执行的作业,我 和尝试以触发构建的用户"身份运行构建,但没有帮助.

但这似乎还不够.

如何解决这些权限问题并使 Jenkins 使用全局安装的 Composer 软件包的二进制文件?

解决方案

似乎无法从/by 执行 (Composer) 存储在另一个 (root) 用户的子文件夹中的二进制文件詹金斯.

对我有用的解决方法是将 COMPOSER_HOME 移动到 Jenkins 有权访问的文件夹,例如:

$ mv/root/.composer/usr/share/.composer$ nano/etc/environment...路径=...COMPOSER_HOME="/usr/share/.composer"...$ nano ~/.profile...出口路径=$PATH:$COMPOSER_HOME/vendor/bin...

PATH 环境变量需要在 Jenkins 配置中设置(Manage Jenkins -> Configure System -> Global properties -> Environment variables)$PATH:$COMPOSER_HOME/vendor/bin/:

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 globally installed Composer packages?

解决方案

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/:

这篇关于如何让 Jenkins 使用 root 用户的子文件夹中的二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆