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 Details

    • MonitoringDefaultAction

      public MonitoringDefaultAction(Run<?,?> run)
      Creates a new instance of MonitoringDefaultAction.
      Parameters:
      run - the run that owns this action.
  • Method Details

    • getIconFileName

      public String getIconFileName()
      Specified by:
      getIconFileName in interface Action
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Action
      Specified by:
      getDisplayName in interface ModelObject
    • getUrlName

      public String getUrlName()
      Specified by:
      getUrlName in interface Action
    • onAttached

      public void onAttached(Run<?,?> build)
      Specified by:
      onAttached in interface RunAction2
    • onLoad

      public void onLoad(Run<?,?> build)
      Specified by:
      onLoad in interface RunAction2
    • getRun

      public Run<?,?> getRun()
    • getPortlets

      public String getPortlets()
    • getObjectMetadataAction

      public Optional<jenkins.scm.api.metadata.ObjectMetadataAction> getObjectMetadataAction()
      Get the ObjectMetadataAction for the current build.
      Returns:
      the ObjectMetadataAction.
    • getContributorMetadataAction

      public Optional<jenkins.scm.api.metadata.ContributorMetadataAction> getContributorMetadataAction()
      Get the ContributorMetadataAction for the current build.
      Returns:
      the ContributorMetadataAction.
    • getScmHead

      public jenkins.scm.api.mixin.ChangeRequestSCMHead2 getScmHead()
      Get the ChangeRequestSCMHead2 for a specific Run.
      Returns:
      the ChangeRequestSCMHead2 of run.
    • getPullRequestMetadataTitle

      public String getPullRequestMetadataTitle()
      Creates the heading for the pull request metadata accordion.
      Returns:
      the title as html element.
    • getPullRequestReferenceBuildDescription

      public String getPullRequestReferenceBuildDescription()
      Creates the reference build link for the pull request metadata title.
      Returns:
      the reference build as html element.
    • getPullRequestMetadataBody

      public String getPullRequestMetadataBody()
      Creates the body for the pull request metadata accordion.
      Returns:
      the body as html element.
    • getConfigurationId

      public String getConfigurationId()
      Get the project it based on the current Run.
      Returns:
      the display name of the current project as id.
    • getUnavailablePortlets

      public List<String> getUnavailablePortlets()
      Get all portlets, which are not available anymore.
      Returns:
      a list of all unavailable portlet ids.
    • 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

      public boolean areJsonNodesEquals(String s1, String s2)
      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

      @JavaScriptMethod public void updateMonitorConfiguration(String config)
      Saves the actual dashboard configuration to MonitorConfigurationProperty.
      Parameters:
      config - the config string to update.
    • getConfiguration

      @JavaScriptMethod public String getConfiguration()
      Get the current dashboard configuration of user.
      Returns:
      the config of the corresponding MonitorConfigurationProperty of the actual project or the default configuration of Jenkinsfile if no config exists in MonitorConfigurationProperty for 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

      @JavaScriptMethod public String resolvePortlets()
      Resolves the portlet string of the Monitor.
      Returns:
      the portlet string of MonitoringCustomAction if exists, else the one of MonitoringDefaultAction.
    • resetMonitorConfiguration

      @JavaScriptMethod public void resetMonitorConfiguration()
      Reset the current project configuration to default.
    • getTarget

      public Object getTarget()
      Specified by:
      getTarget in interface org.kohsuke.stapler.StaplerProxy
    • getAvailablePortlets

      public static List<? extends MonitorPortlet> getAvailablePortlets(Run<?,?> build)
      Gets all MonitorPortlet for corresponding MonitorPortletFactory.
      Parameters:
      build - the reference build.
      Returns:
      all available MonitorPortlet.
    • getFactories

      public static List<? extends MonitorPortletFactory> getFactories()
      Get all portlet factories, type of MonitorPortletFactory.
      Returns:
      all factories as list.
    • getAvailablePortletsForFactory

      public static List<? extends MonitorPortlet> getAvailablePortletsForFactory(Run<?,?> build, MonitorPortletFactory factory)
      Parameters:
      build - the build to get the portlets for.
      factory - the factory to get the portlets for.
      Returns:
      the filtered portlets.