您的位置:首页 > 其它

jenkins 创建用户角色项目权限

2018-03-28 14:28 330 查看

安装Role-Based Strategy插件


插件的官网文档1、安装插件后,进入系统设置页面,配置如下:

保存之后,再点击 系统管理页面点击Manage and Assign Roles进入角色管理页面:

1、管理角色(Manage Roles) 
2、角色权限配置

这里我们暂时回到系统管理 – 管理用户:

点击新建用户:

如果之前有项目与scm版本管理系统(如svn、git等)连接并获取源码构建过,jenkins会从svn中读取到一些用户信息,可以在查看用户菜单中看到这些用户



点击相应的用户标识后,再点击 
设置
按钮,可以修改密码等个人信息。之后我们再回到
Manage and Assign Roles
 –> 
Manage Roles
:

关于pattern处的填写:官方文档介绍该选项支持正则表达式,如
Roger-.
表示所有以Roger-开头的项目, 
(?i)roger-.*
表示以
roger-
开头的项目并且不区分大小写, 
如以
ABC
开头的项目可以配置为
ABC|ABC.*
, 
官方文档> https://wiki.jenkins-ci.org/display/JENKINS/Role+Strategy+Plugin我们再来配置
Assign Roles
系统配置 – 
Manage and Assign Roles
 – 
Assign Roles


点击保存后,就OK了。 
以为上面的例子为例,用户名
zhougz
登录后只能看到项目名为
ggindex
的项目。由于jenkins是英文,所以最好赋上一张jenkins权限的图;

Pattern处详解

There's nothing much to say here, this is self-explanatory. The only tricky field is the Pattern one. This field consists in a regular expression aimed at matching the full name (including the folder name, if you're using Cloudbees Folders Plugin) of the jobs which the role will apply to. For example, if you set the field to "Roger-.*", then the role will match all jobs which name starts with "Roger-". Note that the pattern is case-sensitive. To perform a case-insensitive match, use (?i) notation: upper, "Roger-.*" vs. lower, "roger-.*" vs. case-insensitive, "(?i)roger-.*". If you have a nested folder structure where you want to provide the particular access to the second folder (or deeper), consider having a two-level security structure as well (Say you want to provide exclusive write/ modify type access to foo/bar and not everything else under "foo": First, assign that user/ group to read/ discover permissions with pattern " ^foo.* ", then assign that same user/ group to the more particular permissions with pattern " ^foo/bar.* " - Similar to what you'd do in a Unix/ Linux environment.
1
中文意思:这没什么好说的,已经不言而喻啦!这里唯一棘手的事情就是Pattern。这个pattern是在于针对匹配正则表达式的全名(包括文件夹的名称,如果你使用Cloudbees文件夹插件)将适用于的工作角色。例如:如果你在pattern处输入“Roger-.*”,这个角色将匹配所有jobs中name以”Roger-“开头。注意,这个正则表达式区别大小写的。要是不想区分大小写, 
可以使用(?i)符号:首字母大写”Roger-.” vs 小写”roger-.” vs 不区别大小写 
“(?i)roger-.*”。 
如果你有一个嵌套文件夹结构,你需要提供特定的访问第二个文件夹(或深度),考虑有两级安全结构(说你想提供独家编写/修改类型访问foo / bar和没有其他“foo”:首先,分配用户/组读/发现权限模式”^ foo。”,然后分配相同的用户/组的更特定的权限模式”^ foo / bar。”——类似于Unix / Linux环境中你会做什么。参考地址https://wiki.jenkins-ci.org/display/JENKINS/Role+Strategy+Plugin 
http://www.cnblogs.com/love19791125/p/5113980.html 
http://www.cnblogs.com/davidwang456/p/3701972.html 
http://www.cnblogs.com/zz0412/p/jenkins_jj_14.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: