Jenkins-如何配置受限制但有用的用户帐户

问题描述

在Jenkins中-如何配置受限但有用的用户帐户,该帐户可以:仅查看,取消和重播选定作业的运行?

解决方法

(在Jenkins 2.235上测试)

  1. 配置全局安全性(针对所有项目/职位):
Login as admin.
Manage Jenkins.
Configure Global Security.
Project-based Matrix Authorization Strategy.
Add user or group.
User or group name.
<enter username>
Check the following checkboxes:
Overall.Read
Agent.Build,Job.Build,Job.Cancel,Run.Delete,Run.Replay,Run.Update
Save
  1. 配置本地安全性(针对选定的项目/职位):
Jenkins->All
<choose existing pipeline>
<select dropdown on the pipeline name>
Configure
Enable project-based security <checkbox>
Add user or group
User or group name
<enter username>
Check the following checkboxes:
Job.Build,Job.Read,Run.Update,Save
Logout
  1. 测试
Login as <username>
you should see only one pipeline
Test if Build Now works (this action is by default disabled)
Switch to Blue Ocean view
Message should say: "Started by user <username>"
Click the Stop button on the latest run
Status should change to "aborted"
Click on the Rerun button
<refresh>
Message should change to "Replayed #<run ID>"

请注意,Github OAuth Plugin与基于项目的矩阵授权策略很好地集成在一起,仅在这种情况下,必须使用现有的Github用户名来代替Jenkins内部用户名。授权Github项目合作者运行Jenkins构建。

,

更具扩展性的替代方法是使用Role-based Authorization Strategy Jenkins插件。但是,不要在家尝试,因为它似乎需要LDAP服务器:

  1. 安装插件

  2. 启用插件: 管理詹金斯->配置全局安全性->授权:基于角色的策略->保存

  3. 创建新角色,例如管道用户: 管理詹金斯->未分类:管理和分配角色->管理角色->全局角色->要添加的角色->管道用户->添加->添加这些角色(使用复选框):总体,读取,作业,构建,作业.Cancel,Job.Read,Run.Delete,Run.Replay,Run.Update->保存

  4. 为用户分配新创建的角色 管理詹金斯->未分类:管理和分配角色->分配角色->全局角色->要添加的用户->->添加->管道用户->要添加的用户->->添加->管道用户->保存

尝试以user1身份登录后,Jenkins无法正确识别user1权限。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...