Class PluginImpl

    • Field Detail

      • DEFAULT_NR_OF_SCAN_THREADS

        public static final int DEFAULT_NR_OF_SCAN_THREADS
        Default number of concurrent scan threads.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_LOG_SIZE

        public static final int DEFAULT_MAX_LOG_SIZE
        Default max size of log to be scanned ('0' disables check).
        See Also:
        Constant Field Values
      • DEFAULT_SLACK_CHANNEL

        public static final String DEFAULT_SLACK_CHANNEL
        Default slack channel to use.
        See Also:
        Constant Field Values
      • DEFAULT_SLACK_FAILURE_CATEGORIES

        public static final String DEFAULT_SLACK_FAILURE_CATEGORIES
        Default value for which failure categories to notify slack.
        See Also:
        Constant Field Values
      • PERMISSION_GROUP

        public static final PermissionGroup PERMISSION_GROUP
        The permission group for all permissions related to this plugin.
      • UPDATE_PERMISSION

        public static final Permission UPDATE_PERMISSION
        Permission to update the causes. E.e. Access CauseManagement.
      • VIEW_PERMISSION

        public static final Permission VIEW_PERMISSION
        Permission to view the causes. E.e. Access CauseManagement.
      • REMOVE_PERMISSION

        public static final Permission REMOVE_PERMISSION
        Permission to remove causes.
    • Constructor Detail

      • PluginImpl

        @DataBoundConstructor
        public PluginImpl()
        Default constructor.
    • Method Detail

      • readResolve

        protected Object readResolve()
      • stop

        @Terminator
        public void stop()
        Run on Jenkins shutdown.
      • getStaticResourcesBase

        public static String getStaticResourcesBase()
        Returns the base relative URI for static resources packaged in webapp.
        Returns:
        the base URI.
      • getSodVariables

        public ScanOnDemandVariables getSodVariables()
        Getter sodVariable.
        Returns:
        the message.
      • getStaticImagesBase

        public static String getStaticImagesBase()
        Returns the base relative URI for static images packaged in webapp.
        Returns:
        the images directory.
        See Also:
        getStaticResourcesBase()
      • getImageUrl

        public static String getImageUrl​(String size,
                                         String name)
        Provides a Jenkins relative url to a plugin internal image.
        Parameters:
        size - the size of the image (the sub directory of images).
        name - the name of the image file.
        Returns:
        a URL to the image.
      • getFullImageUrl

        public static String getFullImageUrl​(String size,
                                             String name)
        Get the full url to an image, including rootUrl and context path.
        Parameters:
        size - the size of the image (the sub directory of images).
        name - the name of the image file.
        Returns:
        a URL to the image.
      • getInstance

        @NonNull
        public static PluginImpl getInstance()
        Returns the singleton instance.
        Returns:
        the one.
      • getNoCausesMessage

        public String getNoCausesMessage()
        Getter for the no causes message.
        Returns:
        the message.
      • isNoCausesEnabled

        public boolean isNoCausesEnabled()
        Whether to display in the build page when no causes are identified.
        Returns:
        true if on.
      • setNoCausesEnabled

        @DataBoundSetter
        public void setNoCausesEnabled​(boolean noCausesEnabled)
        Sets whether the "no indications found" message should be shown in the job page when no causes are found. Default value is true.
        Parameters:
        noCausesEnabled - on or off.
      • isGlobalEnabled

        public boolean isGlobalEnabled()
        If this feature is enabled or not. When on all unsuccessful builds will be scanned. None when off.
        Returns:
        true if on.
      • isDoNotAnalyzeAbortedJob

        public boolean isDoNotAnalyzeAbortedJob()
        If this feature is enabled or not. When on all aborted builds will be ignored.
        Returns:
        true if on.
      • isGraphsEnabled

        public boolean isGraphsEnabled()
        If graphs are enabled or not. Links to graphs and graphs will not be displayed when disabled. It can be enabled only if the knowledgeBase has support for it.
        Returns:
        True if enabled.
      • setGraphsEnabled

        @DataBoundSetter
        public void setGraphsEnabled​(boolean graphsEnabled)
        Sets if graphs are enabled. Default value is false.
        Parameters:
        graphsEnabled - the graph flag
      • setNoCausesMessage

        @DataBoundSetter
        public void setNoCausesMessage​(String noCausesMessage)
        Sets the no causes message.
        Parameters:
        noCausesMessage - the no causes message
      • setKnowledgeBase

        @DataBoundSetter
        public void setKnowledgeBase​(KnowledgeBase knowledgeBase)
        Sets the knowledge base.
        Parameters:
        knowledgeBase - the knowledge base
      • setSodVariables

        @DataBoundSetter
        public void setSodVariables​(ScanOnDemandVariables sodVariables)
        Sets the scan on demand variables.
        Parameters:
        sodVariables - the variables
      • setFallbackCategoriesAsString

        @DataBoundSetter
        public void setFallbackCategoriesAsString​(String categories)
        Sets the categories to be considered as generic. Causes with generic categories will only be found if there are no other, non-generic causes.
        Parameters:
        categories - The space separated list of generic categories
      • getFallbackCategoriesAsString

        public String getFallbackCategoriesAsString()
        Fallback categories.
        Returns:
        Fallback categories
      • isTestResultParsingEnabled

        public boolean isTestResultParsingEnabled()
        If failed test cases should be represented as failure causes.
        Returns:
        True if enabled.
      • getTestResultCategories

        public String getTestResultCategories()
        Get categories to be assigned to failure causes representing failed test cases.
        Returns:
        the categories.
      • getFallbackCategories

        public List<String> getFallbackCategories()
        Get the categories that are considered generic.
        Returns:
        a list of generic categories, never null.
      • isMetricSquashingEnabled

        public boolean isMetricSquashingEnabled()
        If metrics should be squashed to only unique categories per build.
        Returns:
        True if enabled.
      • setDoNotAnalyzeAbortedJob

        @DataBoundSetter
        public void setDoNotAnalyzeAbortedJob​(boolean doNotAnalyzeAbortedJob)
        Sets if this feature is enabled or not. When on all aborted builds will be ignored.
        Parameters:
        doNotAnalyzeAbortedJob - on or off.
      • setGlobalEnabled

        @DataBoundSetter
        public void setGlobalEnabled​(boolean globalEnabled)
        Sets if this feature is enabled or not. When on all unsuccessful builds will be scanned. None when off. Default value is true.
        Parameters:
        globalEnabled - on or off.
      • setTestResultParsingEnabled

        @DataBoundSetter
        public void setTestResultParsingEnabled​(boolean testResultParsingEnabled)
        Sets if failed test cases should be represented as failure causes or not. Default value is false.
        Parameters:
        testResultParsingEnabled - on or off.
      • setTestResultCategories

        @DataBoundSetter
        public void setTestResultCategories​(String testResultCategories)
        Set categories to be assigned to failure causes representing failed test cases.
        Parameters:
        testResultCategories - Space-separated string with categories
      • setMetricSquashingEnabled

        @DataBoundSetter
        public void setMetricSquashingEnabled​(boolean metricSquashingEnabled)
        Sets if metrics should be squashed to only unique categories per build. Default value is false.
        Parameters:
        metricSquashingEnabled - on or off.
      • isGerritTriggerEnabled

        public boolean isGerritTriggerEnabled()
        Send notifications to Gerrit-Trigger-plugin.
        Returns:
        true if on.
      • isSlackNotifEnabled

        public boolean isSlackNotifEnabled()
        Send notifications to Slack.
        Returns:
        true if on.
      • getSlackChannelName

        public String getSlackChannelName()
        Get configured slack channel.
        Returns:
        String - Slack Channel.
      • getSlackFailureCategories

        public String getSlackFailureCategories()
        Get configured slack failure cause categories.
        Returns:
        String - Space separated list of failure cause categories.
      • setGerritTriggerEnabled

        @DataBoundSetter
        public void setGerritTriggerEnabled​(boolean gerritTriggerEnabled)
        Sets if this feature is enabled or not. When on, cause descriptions will be forwarded to Gerrit-Trigger-Plugin. Default value is true.
        Parameters:
        gerritTriggerEnabled - on or off.
      • setSlackNotifEnabled

        @DataBoundSetter
        public void setSlackNotifEnabled​(boolean slackNotifEnabled)
        Sets if this feature is enabled or not. When on, selected failures will be sent to Slack channel.
        Parameters:
        slackNotifEnabled - on or off. null == off.
      • setSlackChannelName

        @DataBoundSetter
        public void setSlackChannelName​(String slackChannelName)
        Set configured slack channel.
        Parameters:
        slackChannelName - null = DEFAULT_SLACK_CHANNEL
      • setSlackFailureCategories

        @DataBoundSetter
        public void setSlackFailureCategories​(String slackFailureCategories)
        Set configured slack failure cause categories.
        Parameters:
        slackFailureCategories - - Space seperated list of failure cause categories.
      • getNrOfScanThreads

        public int getNrOfScanThreads()
        The number of threads to have in the pool for each build. Used by the BuildFailureScanner. Will return nothing less than MINIMUM_NR_OF_SCAN_THREADS.
        Returns:
        the number of scan threads.
      • setMaxLogSize

        @DataBoundSetter
        public void setMaxLogSize​(int maxLogSize)
        Set the maximum log size that should be scanned.
        Parameters:
        maxLogSize - value
      • getMaxLogSize

        public int getMaxLogSize()
        Returns the maximum log size that should be scanned.
        Returns:
        value
      • needToAnalyze

        public static boolean needToAnalyze​(Result result)
        Checks if the build with certain result should be analyzed or not.
        Parameters:
        result - the result
        Returns:
        true if it should be analyzed.
      • shouldScan

        public static boolean shouldScan​(Run build)
        Checks if the specified build should be scanned or not.
        Parameters:
        build - the build
        Returns:
        true if it should be scanned.
        See Also:
        shouldScan(Job)
      • isSizeInLimit

        public static boolean isSizeInLimit​(Run build)
        Checks that log size is in limits.
        Parameters:
        build - the build
        Returns:
        true if size is in limit.
      • shouldScan

        public static boolean shouldScan​(Job project)
        Checks if the specified project should be scanned or not. Determined by isGlobalEnabled() and if the project has ScannerJobProperty.isDoNotScan().
        Parameters:
        project - the project
        Returns:
        true if it should be scanned.
      • getKnowledgeBase

        public KnowledgeBase getKnowledgeBase()
        The knowledge base containing all causes.
        Returns:
        all the base.
      • getKnowledgeBaseDescriptor

        public KnowledgeBase.KnowledgeBaseDescriptor getKnowledgeBaseDescriptor​(String descString)
        Gets the KnowledgeBaseDescriptor that matches the name descString.
        Parameters:
        descString - either name of a KnowledgeBaseDescriptor or the fully qualified name.
        Returns:
        The matching KnowledgeBaseDescriptor or null if none is found.
      • configure

        public boolean configure​(org.kohsuke.stapler.StaplerRequest req,
                                 net.sf.json.JSONObject o)
        Overrides:
        configure in class GlobalConfiguration
      • getCategoryAutoCompletionCandidates

        public AutoCompletionCandidates getCategoryAutoCompletionCandidates​(String prefix)
        Does the auto completion for categories, matching with any category already present in the knowledge base.
        Parameters:
        prefix - the input prefix.
        Returns:
        the AutoCompletionCandidates.
      • doAutoCompleteFallbackCategoriesAsString

        public AutoCompletionCandidates doAutoCompleteFallbackCategoriesAsString​(@QueryParameter
                                                                                 String value)
        Does the auto completion for categories, matching with any category already present in the knowledge base.
        Parameters:
        value - the input value.
        Returns:
        the AutoCompletionCandidates.