jenkins slave以用户身份运行 [英] jenkins slave runs as user

查看:622
本文介绍了jenkins slave以用户身份运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个用户的jenkins设置,这些用户使用 Active Directory插件.这很有用,这样每个用户都可以访问自己的任务.

I have a jenkins setup with multiple users which are logging in with Active Directory plugin. This is useful so that each user can access his own tasks.

但是,每个用户在本地网络上也具有不同的权限,例如访问不同的文件夹等.我注意到,分配给每个任务的权限并不链接到用户,而是链接到从属运行时所使用的帐户.服务.有没有一种方法可以更改此任务,以便在用户的凭据(并因此具有权限)下在从属服务器上执行任务?

However each user also has different permissions on the local network, such as access to different folders etc. I have noticed that the permissions given to each task is not linked to the user but to the account under which the slave is running as service. Is there a way to change that so that the task is executed on the slave under the credential (and hence permissions) of the user?

谢谢

推荐答案

问题是:只有一个从属进程运行Jenkins主服务器分配给该服务器的不同作业.
因此,从属服务器本身以一个用户(通常是专用帐户或系统帐户)的身份运行.

The problem is: there is only one slave process running the different job assigned to that server by the Jenkins master.
So the slave itself runs as one user (generally, a dedicated account or a system account).

因为您可以将用户ID作为环境变量获取(使用 例如,请参见 JENKINS授权项目插件.

Since you can get the user id as environment variable (with a plugin like JENKINS Build User Vars Plugin), you might consider configuring the job in order for it build step to "run as" the user who triggered the build.
See for instance the JENKINS Authorize Project plugin.

但是,正如提到了这个答案:

授权项目"插件不会更改正在运行命令的OS级用户.
它仅使用Jenkins身份验证(无论它是什么)来设置正在运行作业的Jenkins用户和任何下游作业.

The "Authorize Project" plugin does not change the OS level user that is running commands.
It only sets the Jenkins user that is running the job and any downstream jobs, using Jenkins authentication (whatever it might be).

因此,您剩下的是使用runas或su -c命令构建步骤,以便确保确定您的任务确实由正确的用户运行.

So you are left with build step with runas or su -c commands in order to be sure that your task does run with the right user.

这篇关于jenkins slave以用户身份运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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