The plugin provides REST APIs for modifying the roles. All of these methods
require the user invoking them to have the Jenkins.ADMINISTER
permission.
Adds a global role with no sids assigned to it. Requires POST to ${JENKINS_URL}/folder-auth/addGlobalRole
.
The request body should specify the role to be added as a JSON object. For
example, to add a role with name foo
and providing the Item | Delete
and the Item | Configure
permissions, the request body should look like this:
{
"name": "foo",
"permissions": [
"hudson.model.Item.Delete",
"hudson.model.Item.Configure"
]
}
For example, you can add the role using curl
like this:
curl -X POST -H "Content-Type: application/json" -d \
'{
"name": "foo",
"permissions": [
"hudson.model.Item.Delete",
"hudson.model.Item.Configure"
]
}' localhost:8080/folder-auth/addGlobalRole
Adds a folder role with no sids assigned to it. Requires POST to ${JENKINS_URL}/folder-auth/addFolderRole
.
The request body should specify the role to be added as a JSON object. For
example, to add a role with name foo
and providing the`Item | Delete` and
the Item | Configure
permissions on folders bar`and `foo/baz
, the
request body should look like this:
{
"name": "foo",
"permissions": [
"hudson.model.Item.Delete",
"hudson.model.Item.Configure"
],
"folderNames": [
"foo/baz",
"bar"
]
}
Adds an agent role with no sids assigned to it. Requires POST to ${JENKINS_URL}/folder-auth/addAgentRole
.
The request body should specify the role to be added as a JSON object. For
example, to add a role with the equal to foo
and providing the
Agent | Configure
permissions on agents bar
and baz
, the request body
should look like this:
{
"name": "foo",
"permissions": [
"hudson.model.Computer.Configure"
],
"agentNames": [
"bar",
"baz"
]
}
Assigns a sid to the role identified by its name. Requires POST to
${JENKINS_URL}/folder-auth/assignSidToGlobalRole
. The following query
parameters are required:
-
roleName
: The sid will be assigned to the global role with the name equal to this parameter. -
sid
: The sid to be assigned to the role with the name equal to the value ofroleName
.
Using curl
, for example, a sid "foo" can be assigned to the role "bar"
curl -X POST -d 'roleName=bar&sid=foo' \
http://localhost:8080/folder-auth/assignSidToGlobalRole
Assigns a sid to the role identified by its name. Requires POST to
${JENKINS_URL}/folder-auth/assignSidToFolderRole
. The following query
parameters are required:
-
roleName
: The sid will be assigned to the folder role with the name equal to this parameter. -
sid
: The sid to be assigned to the role with the name equal to the value ofroleName
.
Using curl
, for example, a sid "foo" can be assigned to the role "bar"
curl -X POST -d 'roleName=bar&sid=foo' \
http://localhost:8080/folder-auth/assignSidToFolderRole
Assigns a sid to the role identified by its name. Requires POST to
${JENKINS_URL}/folder-auth/assignSidToAgentRole
. The following query
parameters are required:
-
roleName
: The sid will be assigned to the agent role with the name equal to this parameter. -
sid
: The sid to be assigned to the role with the name equal to the value ofroleName
.
Using curl
, for example, a sid "foo" can be assigned to the role "bar"
curl -X POST -d 'roleName=bar&sid=foo' \
http://localhost:8080/folder-auth/assignSidToAgentRole
Deletes a global role identified by its name. Requires POST to
${JENKINS_URL}/folder-auth/deleteGlobalRole
. The query parameter
roleName
is required.
Using curl
, for example, a role with name "foo" can be deleted
curl -X POST -d 'roleName=foo' http://localhost:8080/folder-auth/deleteGlobalRole
Deletes a folder role identified by its name. Requires POST to
${JENKINS_URL}/folder-auth/deleteGlobalRole
. The parameter
roleName
is required.
curl -X POST -d 'roleName=foo' http://localhost:8080/folder-auth/deleteFolderRole
When using cURL to invoke the API, you need to login as a user with the administrator permissions. See the example below for viewing the home page:
curl -X GET -u $USERNAME:$TOKEN http://localhost:8080/
The API token can be obtained by clicking on your logged in user on the top-right of your Jenkins Home page and then clicking the 'Configure' button in the side bar. For more information about authentication, please see https://wiki.jenkins.io/display/JENKINS/Remote+access+API