This example demonstrates how to use the optional Item Roles Admin and Agent Roles Admin permissions to delegate role management responsibilities to non-admin users.
By default, only users with Jenkins ADMINISTER permission can manage roles and role assignments. However, in large organizations, you may want to delegate this responsibility:
- Item Roles Admin (
Role Based Strategy/ItemRoles): Allows users to manage item (job/folder) roles and their assignments - Agent Roles Admin (
Role Based Strategy/AgentRoles): Allows users to manage agent (node) roles and their assignments
These permissions enable you to create "role administrators" who can manage specific types of roles without having full Jenkins administrator access.
The Jenkins.SYSTEM_READ permission can be enabled either via a system property or by using the Extended Read Permission Plugin.
Users who have ITEM_ROLES_ADMIN or AGENT_ROLES_ADMIN and SYSTEM_READ (or ADMINISTER) can access role management through the standard "Manage Jenkins" menu. They will see:
- Manage Jenkins -> Manage and Assign Roles: Standard access path
- They can view all role sections in read-only mode, but can only edit the sections they have permission for
Users who have ITEM_ROLES_ADMIN or AGENT_ROLES_ADMIN without SYSTEM_READ cannot access "Manage Jenkins". For these users, a special root-level link is provided:
- Root Dashboard -> Manage and Assign Roles: Direct link at the Jenkins root level
- This link is only visible to users with role admin permissions but without
SYSTEM_READ - It provides the same functionality as the management link, but accessible without needing to access "Manage Jenkins"
This design ensures that:
- Users with
SYSTEM_READdon't see duplicate links (they use the management link) - Users without
SYSTEM_READcan still access role management directly - Regular users without any admin permissions see no role management links
This directory contains a Configuration-as-Code YAML file that sets up multiple test users to demonstrate all scenarios:
| User | Permissions | Access Method | Can Manage |
|---|---|---|---|
admin |
Overall/Administer | Manage Jenkins | All roles (global, item, agent) |
item-admin |
ItemRoles only | Root-level link | Item roles only |
item-admin-sysread |
ItemRoles + Overall/SystemRead | Manage Jenkins | Item roles only |
agent-admin |
AgentRoles only | Root-level link | Agent roles only |
agent-admin-sysread |
AgentRoles + Overall/SystemRead | Manage Jenkins | Agent roles only |
both-admin |
ItemRoles + AgentRoles | Root-level link | Item and agent roles |
both-admin-sysread |
ItemRoles + AgentRoles + Overall/SystemRead | Manage Jenkins | Item and agent roles |
-
Link Visibility:
- Users with
SYSTEM_READ: See link under "Manage Jenkins" - Users without
SYSTEM_READ: See link at root level
- Users with
-
Page Access:
- All role admin users can access
/role-strategy/pages - Different sections are editable based on their specific permissions
- All role admin users can access
-
Read-Only Sections:
item-admincan edit Item roles but sees Global and Agent roles in read-only modeagent-admincan edit Agent roles but sees Global and Item roles in read-only modeboth-admincan edit Item and Agent roles but sees Global roles in read-only mode
Enable the optional permissions:
export _JAVA_OPTIONS="-Djenkins.security.SystemReadPermission=true -Dcom.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy.useItemAndAgentRoles=true -Dcasc.jenkins.config=$(pwd)/docs/delegating-role-management/jenkins-casc.yaml"mvn hpi:run-
admin / admin
- Go to "Manage Jenkins" � "Manage and Assign Roles"
- Can edit all three sections (Global, Item, Agent)
- Has full control
-
item-admin / item-admin
- Note the root-level link "Manage and Assign Roles" (not under "Manage Jenkins")
- Click it to go to role management
- Can edit Item roles (editable checkboxes, add/delete buttons visible)
- Can view Global and Agent roles in read-only mode (checkboxes disabled, no add/delete buttons)
-
item-admin-sysread / item-admin-sysread
- Go to "Manage Jenkins" � "Manage and Assign Roles"
- Same editing capabilities as
item-admin, but accessed via Manage Jenkins - No root-level link visible
-
agent-admin / agent-admin
- Note the root-level link "Manage and Assign Roles"
- Can edit Agent roles
- Can view Global and Item roles in read-only mode
-
agent-admin-sysread / agent-admin-sysread
- Go to "Manage Jenkins" � "Manage and Assign Roles"
- Same editing capabilities as
agent-admin, but accessed via Manage Jenkins
-
both-admin / both-admin
- Note the root-level link "Manage and Assign Roles"
- Can edit both Item and Agent roles
- Can view Global roles in read-only mode
-
both-admin-sysread / both-admin-sysread
- Go to "Manage Jenkins" � "Manage and Assign Roles"
- Same editing capabilities as
both-admin, but accessed via Manage Jenkins
- Editable sections: Full table with add/delete buttons, editable checkboxes and patterns
- Read-only sections: Table visible but no add/delete buttons, checkboxes and patterns disabled
- Editable sections: Can add/remove users/groups, check/uncheck role assignments
- Read-only sections: Can view assignments but cannot modify (no add/delete buttons, checkboxes disabled)
- Only visible to users with
ITEM_ROLES_ADMINpermission - Users without this permission will get a 403 error when trying to access it
- Jenkins administrators focus on global security and infrastructure
- Team leads manage item roles for their projects
- Infrastructure team manages agent roles for build nodes
- Each tenant has an "admin" user with
ITEM_ROLES_ADMIN - They can manage roles for their jobs without affecting other tenants
- Central IT retains global role management
- Separation of duties: role management delegated by domain
- Audit trail: different users responsible for different role types
- Principle of least privilege: users only have permissions they need
The implementation uses three key components:
- Permission Definitions:
ITEM_ROLES_ADMINandAGENT_ROLES_ADMINpermissions - RoleStrategyConfig: ManagementLink for users with
SYSTEM_READ - RoleStrategyRootAction: Root-level link for users without
SYSTEM_READ
Both access paths delegate to the same underlying implementation, ensuring consistent behavior regardless of how users access the role management pages.