Package io.jenkins.plugins.monitoring
Class MonitoringDefaultAction
java.lang.Object
io.jenkins.plugins.monitoring.MonitoringDefaultAction
- All Implemented Interfaces:
Action,ModelObject,RunAction2,org.kohsuke.stapler.StaplerProxy
public class MonitoringDefaultAction
extends Object
implements RunAction2, org.kohsuke.stapler.StaplerProxy
This action displays a link on the side panel of a
Run. The action is only displayed if the parent job
is a pull request.
The action is responsible to render the summary via its associated 'summary.jelly' view and render the
main plugin page, where the user can configure the dashboard with all supported plugins via its associated
'index.jelly view.- Author:
- Simon Symhoven
-
Constructor Summary
ConstructorsConstructorDescriptionMonitoringDefaultAction(Run<?, ?> run) Creates a new instance ofMonitoringDefaultAction. -
Method Summary
Modifier and TypeMethodDescriptionbooleanareJsonNodesEquals(String s1, String s2) Compares to json nodes, if they are equals.static List<? extends MonitorPortlet> getAvailablePortlets(Run<?, ?> build) Gets allMonitorPortletfor correspondingMonitorPortletFactory.static List<? extends MonitorPortlet> getAvailablePortletsForFactory(Run<?, ?> build, MonitorPortletFactory factory) Gets allMonitorPortletfor oneMonitorPortletFactory.Get the current dashboard configuration of user.Get the project it based on the currentRun.Optional<jenkins.scm.api.metadata.ContributorMetadataAction> Get theContributorMetadataActionfor the current build.static List<? extends MonitorPortletFactory> Get all portlet factories, type ofMonitorPortletFactory.Optional<jenkins.scm.api.metadata.ObjectMetadataAction> Get theObjectMetadataActionfor the current build.Creates the body for the pull request metadata accordion.Creates the heading for the pull request metadata accordion.Creates the reference build link for the pull request metadata title.Run<?, ?> getRun()jenkins.scm.api.mixin.ChangeRequestSCMHead2Get theChangeRequestSCMHead2for a specificRun.Get all portlets, which are not available anymore.booleanChecks if there are changes in the configuration since the last build.booleanChecks if the actual configuration is synced with the default one (Jenkinsfile or empty one).voidonAttached(Run<?, ?> build) voidvoidReset the current project configuration to default.Resolves the portlet string of theMonitor.voidupdateMonitorConfiguration(String config) Saves the actual dashboard configuration toMonitorConfigurationProperty.
-
Constructor Details
-
MonitoringDefaultAction
Creates a new instance ofMonitoringDefaultAction.- Parameters:
run- the run that owns this action.
-
-
Method Details
-
getIconFileName
- Specified by:
getIconFileNamein interfaceAction
-
getDisplayName
- Specified by:
getDisplayNamein interfaceAction- Specified by:
getDisplayNamein interfaceModelObject
-
getUrlName
- Specified by:
getUrlNamein interfaceAction
-
onAttached
- Specified by:
onAttachedin interfaceRunAction2
-
onLoad
- Specified by:
onLoadin interfaceRunAction2
-
getRun
-
getPortlets
-
getObjectMetadataAction
Get theObjectMetadataActionfor the current build.- Returns:
- the
ObjectMetadataAction.
-
getContributorMetadataAction
Get theContributorMetadataActionfor the current build.- Returns:
- the
ContributorMetadataAction.
-
getScmHead
public jenkins.scm.api.mixin.ChangeRequestSCMHead2 getScmHead()Get theChangeRequestSCMHead2for a specificRun.- Returns:
- the
ChangeRequestSCMHead2of run.
-
getPullRequestMetadataTitle
Creates the heading for the pull request metadata accordion.- Returns:
- the title as html element.
-
getPullRequestReferenceBuildDescription
Creates the reference build link for the pull request metadata title.- Returns:
- the reference build as html element.
-
getPullRequestMetadataBody
Creates the body for the pull request metadata accordion.- Returns:
- the body as html element.
-
getConfigurationId
Get the project it based on the currentRun.- Returns:
- the display name of the current project as id.
-
hasChanges
public boolean hasChanges()Checks if there are changes in the configuration since the last build.- Returns:
- true if both configurations are equal, else false.
-
areJsonNodesEquals
Compares to json nodes, if they are equals.- Parameters:
s1- the first json node as string.s2- the second json node as string.- Returns:
- true, if both are equals, else false.
-
updateMonitorConfiguration
Saves the actual dashboard configuration toMonitorConfigurationProperty.- Parameters:
config- the config string to update.
-
getConfiguration
Get the current dashboard configuration of user.- Returns:
- the config of the corresponding
MonitorConfigurationPropertyof the actual project or the default configuration of Jenkinsfile if no config exists inMonitorConfigurationPropertyfor actual project.
-
isMonitorConfigurationSynced
@JavaScriptMethod public boolean isMonitorConfigurationSynced()Checks if the actual configuration is synced with the default one (Jenkinsfile or empty one).- Returns:
- true, if synced, else false.
-
resolvePortlets
Resolves the portlet string of theMonitor.- Returns:
- the portlet string of
MonitoringCustomActionif exists, else the one ofMonitoringDefaultAction.
-
resetMonitorConfiguration
@JavaScriptMethod public void resetMonitorConfiguration()Reset the current project configuration to default. -
getTarget
- Specified by:
getTargetin interfaceorg.kohsuke.stapler.StaplerProxy
-
getAvailablePortlets
Gets allMonitorPortletfor correspondingMonitorPortletFactory.- Parameters:
build- the reference build.- Returns:
- all available
MonitorPortlet.
-
getFactories
Get all portlet factories, type ofMonitorPortletFactory.- Returns:
- all factories as list.
-
getAvailablePortletsForFactory
public static List<? extends MonitorPortlet> getAvailablePortletsForFactory(Run<?, ?> build, MonitorPortletFactory factory) Gets allMonitorPortletfor oneMonitorPortletFactory.- Parameters:
build- the build to get the portlets for.factory- the factory to get the portlets for.- Returns:
- the filtered portlets.
-