public abstract class AdministrativeMonitor extends AbstractModelObject implements ExtensionPoint, org.kohsuke.stapler.StaplerProxy
Plugins who wish to contribute such notifications can implement this
class and put Extension
on it to register it to Jenkins.
Once installed, it's the implementer's responsibility to perform
monitoring and activate/deactivate the monitor accordingly. Sometimes
this can be done by updating a flag from code (see SCMTrigger
for one such example), while other times it's more convenient to do
so by running some code periodically (for this, use Trigger.timer
)
AdministrativeMonitor
s are bound to URL by Jenkins.getAdministrativeMonitor(String)
.
See getUrl()
.
isActivated()
returns true, Jenkins will use the message.jelly
view of this object to render the warning text. This happens in the
http://SERVER/jenkins/manage
page. This view should typically render
a DIV box with class='alert alert-danger' or class='alert alert-warning' with a human-readable text
inside it. It often also contains a link to a page that provides more details
about the problem.
By default administrative monitors are visible only to users with Administer permission.
Users with Jenkins.SYSTEM_READ
permission can access administrative monitors that override getRequiredPermission()
.
Care needs to be taken to ensure users with that permission don't have access to actions modifying system state.
For more details, see getRequiredPermission()
.
Jenkins.administrativeMonitors
ExtensionPoint.LegacyInstancesAreScopedToHudson
Modifier and Type | Field and Description |
---|---|
String |
id
Human-readable ID of this monitor, which needs to be unique within the system.
|
Modifier | Constructor and Description |
---|---|
protected |
AdministrativeMonitor() |
protected |
AdministrativeMonitor(String id) |
Modifier and Type | Method and Description |
---|---|
static ExtensionList<AdministrativeMonitor> |
all()
All registered
AdministrativeMonitor instances. |
void |
disable(boolean value)
Mark this monitor as disabled, to prevent this from showing up in the UI.
|
void |
doDisable(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
URL binding to disable this monitor.
|
String |
getDisplayName() |
Permission |
getRequiredPermission()
Required permission to view this admin monitor.
|
String |
getSearchUrl()
Returns the URL of this item relative to the parent
SearchItem . |
Object |
getTarget()
Ensure that URLs in this administrative monitor are only accessible to users with
getRequiredPermission() . |
String |
getUrl()
Returns the URL of this monitor, relative to the context path, like "administrativeMonitor/foobar".
|
abstract boolean |
isActivated()
Returns true if this monitor is activated and
wants to produce a warning message.
|
boolean |
isEnabled()
Returns true if this monitor
isn't disabled earlier. |
boolean |
isSecurity()
Returns true if this monitor is security related.
|
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
public final String id
This ID is used to remember persisted setting for this monitor, so the ID should remain consistent beyond the Hudson JVM lifespan.
protected AdministrativeMonitor(String id)
protected AdministrativeMonitor()
public String getUrl()
public String getDisplayName()
getDisplayName
in interface ModelObject
public final String getSearchUrl()
SearchItem
SearchItem
.getSearchUrl
in interface SearchItem
public void disable(boolean value) throws IOException
IOException
public boolean isEnabled()
isn't disabled
earlier.
This flag implements the ability for the admin to say "no thank you" to the monitor that he wants to ignore.
public abstract boolean isActivated()
This method is called from the HTML rendering thread, so it should run efficiently.
public boolean isSecurity()
public void doDisable(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException
IOException
public Permission getRequiredPermission()
Jenkins.ADMINISTER
, but Jenkins.SYSTEM_READ
is also supported.
Changing this permission check to return Jenkins.SYSTEM_READ
will make the active
administrative monitor appear on manage.jelly
and on the globally visible
AdministrativeMonitorsDecorator
to users without Administer permission.
doDisable(StaplerRequest, StaplerResponse)
will still always require Administer permission.
Implementers need to ensure that doAct
and other web methods perform necessary permission checks:
Users with System Read permissions are expected to be limited to read-only access.
Form UI elements that change system state, e.g. toggling a feature on or off, need to be hidden from users
lacking Administer permission.
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getTarget()
getRequiredPermission()
.getTarget
in interface org.kohsuke.stapler.StaplerProxy
public static ExtensionList<AdministrativeMonitor> all()
AdministrativeMonitor
instances.Copyright © 2004–2021. All rights reserved.