Class ApprovalContext
java.lang.Object
org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext
Represents background information about who requested that a script or signature be approved and for what purpose.
When created from a thread that generally carries authentication, such as within a
DataBoundConstructor
, be sure to use withCurrentUser()
.
Also use withItem(hudson.model.Item)
or withKey(java.lang.String)
or withItemAsKey(hudson.model.Item)
whenever possible.-
Method Summary
Modifier and TypeMethodDescriptionstatic ApprovalContext
create()
Creates a new context with no information.getItem()
Gets any associated item which should be displayed to an administrator.getKey()
Gets the unique key, if any.getUser()
Gets the associated user ID, if any.Creates a context with the user associated with the current thread.Associates an item with this approval, used only for display purposes.withItemAsKey
(Item item) Associates an item with this approval for display, as well as setting a unique key based on theItem.getFullName()
which would cancel any previous approvals for the same item.Associates a unique key with this approval.Creates a context with a specified user ID.
-
Method Details
-
create
Creates a new context with no information. -
withUser
Creates a context with a specified user ID. (ACL.SYSTEM2
is automatically ignored.) -
withCurrentUser
Creates a context with the user associated with the current thread. (ACL.SYSTEM2
is automatically ignored, but the user might beJenkins.ANONYMOUS2
.) -
getUser
Gets the associated user ID, if any. -
withItem
Associates an item with this approval, used only for display purposes. -
getItem
Gets any associated item which should be displayed to an administrator. -
withKey
Associates a unique key with this approval. If not null, any previous approval of the same kind with the same key will be canceled and replaced by this one. Only considered for whole-script approvals, not signature approvals which are generic. -
getKey
Gets the unique key, if any. -
withItemAsKey
Associates an item with this approval for display, as well as setting a unique key based on theItem.getFullName()
which would cancel any previous approvals for the same item. Note that this only makes sense in cases where it is guaranteed that at most one approvable script is configured on a given item, so do not use this with (for example) build steps.
-