Class PluginImpl
- java.lang.Object
-
- hudson.model.Descriptor<GlobalConfiguration>
-
- jenkins.model.GlobalConfiguration
-
- com.sonyericsson.jenkins.plugins.bfa.PluginImpl
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<GlobalConfiguration>
,Saveable
,OnMaster
@Extension @Symbol("buildFailureAnalyzer") public class PluginImpl extends GlobalConfiguration
The main thing.- Author:
- Robert Sandell <robert.sandell@sonyericsson.com>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_ICON_NAME
Convenience constant for the default icon size.static String
DEFAULT_ICON_SIZE
Convenience constant for the 24x24 icon size.static int
DEFAULT_MAX_LOG_SIZE
Default max size of log to be scanned ('0' disables check).static int
DEFAULT_NR_OF_SCAN_THREADS
Default number of concurrent scan threads.static String
DEFAULT_SLACK_CHANNEL
Default slack channel to use.static String
DEFAULT_SLACK_FAILURE_CATEGORIES
Default value for which failure categories to notify slack.protected static int
MINIMUM_NR_OF_SCAN_THREADS
Minimum allowed value fornrOfScanThreads
.static PermissionGroup
PERMISSION_GROUP
The permission group for all permissions related to this plugin.static Permission
REMOVE_PERMISSION
Permission to remove causes.static Permission
UPDATE_PERMISSION
Permission to update the causes.static Permission
VIEW_PERMISSION
Permission to view the causes.-
Fields inherited from class hudson.model.Descriptor
clazz
-
-
Constructor Summary
Constructors Constructor Description PluginImpl()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject o)
AutoCompletionCandidates
doAutoCompleteFallbackCategoriesAsString(String value)
Does the auto completion for categories, matching with any category already present in the knowledge base.AutoCompletionCandidates
getCategoryAutoCompletionCandidates(String prefix)
Does the auto completion for categories, matching with any category already present in the knowledge base.XmlFile
getConfigFile()
static String
getDefaultIcon()
The default icon to be used throughout this plugin.List<String>
getFallbackCategories()
Get the categories that are considered generic.String
getFallbackCategoriesAsString()
Fallback categories.static String
getFullImageUrl(String size, String name)
Get the full url to an image, including rootUrl and context path.static String
getImageUrl(String name)
Provides a Jenkins relative url to a plugin internal image ofDEFAULT_ICON_SIZE
size.static String
getImageUrl(String size, String name)
Provides a Jenkins relative url to a plugin internal image.static PluginImpl
getInstance()
Returns the singleton instance.KnowledgeBase
getKnowledgeBase()
The knowledge base containing all causes.KnowledgeBase.KnowledgeBaseDescriptor
getKnowledgeBaseDescriptor(String descString)
Gets the KnowledgeBaseDescriptor that matches the name descString.ExtensionList<KnowledgeBase.KnowledgeBaseDescriptor>
getKnowledgeBaseDescriptors()
Convenience method to reach the list from jelly.int
getMaxLogSize()
Returns the maximum log size that should be scanned.String
getNoCausesMessage()
Getter for the no causes message.int
getNrOfScanThreads()
The number of threads to have in the pool for each build.String
getSlackChannelName()
Get configured slack channel.String
getSlackFailureCategories()
Get configured slack failure cause categories.ScanOnDemandVariables
getSodVariables()
Getter sodVariable.static String
getStaticImagesBase()
Returns the base relative URI for static images packaged in webapp.static String
getStaticResourcesBase()
Returns the base relative URI for static resources packaged in webapp.String
getTestResultCategories()
Get categories to be assigned to failure causes representing failed test cases.boolean
isDoNotAnalyzeAbortedJob()
If this feature is enabled or not.boolean
isGerritTriggerEnabled()
Send notifications to Gerrit-Trigger-plugin.boolean
isGlobalEnabled()
If this feature is enabled or not.boolean
isGraphsEnabled()
If graphs are enabled or not.boolean
isMetricSquashingEnabled()
If metrics should be squashed to only unique categories per build.boolean
isNoCausesEnabled()
Whether to display in the build page when no causes are identified.static boolean
isSizeInLimit(Run build)
Checks that log size is in limits.boolean
isSlackNotifEnabled()
Send notifications to Slack.boolean
isTestResultParsingEnabled()
If failed test cases should be represented as failure causes.static boolean
needToAnalyze(Result result)
Checks if the build with certain result should be analyzed or not.protected Object
readResolve()
void
setDoNotAnalyzeAbortedJob(boolean doNotAnalyzeAbortedJob)
Sets if this feature is enabled or not.void
setFallbackCategoriesAsString(String categories)
Sets the categories to be considered as generic.void
setGerritTriggerEnabled(boolean gerritTriggerEnabled)
Sets if this feature is enabled or not.void
setGlobalEnabled(boolean globalEnabled)
Sets if this feature is enabled or not.void
setGraphsEnabled(boolean graphsEnabled)
Sets if graphs are enabled.void
setKnowledgeBase(KnowledgeBase knowledgeBase)
Sets the knowledge base.void
setMaxLogSize(int maxLogSize)
Set the maximum log size that should be scanned.void
setMetricSquashingEnabled(boolean metricSquashingEnabled)
Sets if metrics should be squashed to only unique categories per build.void
setNoCausesEnabled(boolean noCausesEnabled)
Sets whether the "no indications found" message should be shown in the job page when no causes are found.void
setNoCausesMessage(String noCausesMessage)
Sets the no causes message.void
setNrOfScanThreads(int nrOfScanThreads)
The number of threads to have in the pool for each build.void
setSlackChannelName(String slackChannelName)
Set configured slack channel.void
setSlackFailureCategories(String slackFailureCategories)
Set configured slack failure cause categories.void
setSlackNotifEnabled(boolean slackNotifEnabled)
Sets if this feature is enabled or not.void
setSodVariables(ScanOnDemandVariables sodVariables)
Sets the scan on demand variables.void
setTestResultCategories(String testResultCategories)
Set categories to be assigned to failure causes representing failed test cases.void
setTestResultParsingEnabled(boolean testResultParsingEnabled)
Sets if failed test cases should be represented as failure causes or not.static boolean
shouldScan(Job project)
Checks if the specified project should be scanned or not.static boolean
shouldScan(Run build)
Checks if the specified build should be scanned or not.void
start()
Starts the knowledge base.void
stop()
Run on Jenkins shutdown.-
Methods inherited from class jenkins.model.GlobalConfiguration
all, getDescriptor, getGlobalConfigPage
-
Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getDisplayName, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
-
-
-
Field Detail
-
DEFAULT_ICON_SIZE
public static final String DEFAULT_ICON_SIZE
Convenience constant for the 24x24 icon size. used forgetImageUrl(String, String)
.- See Also:
- Constant Field Values
-
DEFAULT_ICON_NAME
public static final String DEFAULT_ICON_NAME
Convenience constant for the default icon size. used forgetImageUrl(String, String)
.- See Also:
- Constant Field Values
-
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. AccessCauseManagement
.
-
VIEW_PERMISSION
public static final Permission VIEW_PERMISSION
Permission to view the causes. E.e. AccessCauseManagement
.
-
REMOVE_PERMISSION
public static final Permission REMOVE_PERMISSION
Permission to remove causes.
-
MINIMUM_NR_OF_SCAN_THREADS
protected static final int MINIMUM_NR_OF_SCAN_THREADS
Minimum allowed value fornrOfScanThreads
.- See Also:
- Constant Field Values
-
-
Method Detail
-
readResolve
protected Object readResolve()
-
getConfigFile
public XmlFile getConfigFile()
- Overrides:
getConfigFile
in classDescriptor<GlobalConfiguration>
-
start
@Initializer(after=EXTENSIONS_AUGMENTED) public void start()
Starts the knowledge base.
-
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.
-
getImageUrl
public static String getImageUrl(String name)
Provides a Jenkins relative url to a plugin internal image ofDEFAULT_ICON_SIZE
size.- Parameters:
name
- the name of the image.- Returns:
- a URL to the image.
- See Also:
getImageUrl(String, String)
-
getDefaultIcon
public static String getDefaultIcon()
The default icon to be used throughout this plugin.- Returns:
- the relative URL to the image.
- See Also:
getImageUrl(String)
,getImageUrl(String, String)
-
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 theBuildFailureScanner
. Will return nothing less thanMINIMUM_NR_OF_SCAN_THREADS
.- Returns:
- the number of scan threads.
-
setNrOfScanThreads
@DataBoundSetter public void setNrOfScanThreads(int nrOfScanThreads)
The number of threads to have in the pool for each build. Used by theBuildFailureScanner
. Will throw anIllegalArgumentException
if the parameter is less thanMINIMUM_NR_OF_SCAN_THREADS
.- Parameters:
nrOfScanThreads
- 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 byisGlobalEnabled()
and if the project hasScannerJobProperty.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.
-
getKnowledgeBaseDescriptors
public ExtensionList<KnowledgeBase.KnowledgeBaseDescriptor> getKnowledgeBaseDescriptors()
Convenience method to reach the list from jelly.- Returns:
- the list of registered KnowledgeBaseDescriptors
-
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 classGlobalConfiguration
-
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.
-
-