jenkins 创建用户角色项目权限

安装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

猜你喜欢

转载自blog.csdn.net/qq_27791709/article/details/79727155
今日推荐