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
,Loadable
,OnMaster
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
Modifier and TypeFieldDescriptionstatic final String
Convenience constant for the default icon size.static final String
Convenience constant for the 24x24 icon size.static final int
Default max size of log to be scanned ('0' disables check).static final int
Default number of concurrent scan threads.static final String
Default slack channel to use.static final String
Default value for which failure categories to notify slack.protected static final int
Minimum allowed value fornrOfScanThreads
.static final PermissionGroup
The permission group for all permissions related to this plugin.static final Permission
Permission to remove causes.static final Permission
Permission to update the causes.static final Permission
Permission to view the causes.Fields inherited from class hudson.model.Descriptor
clazz
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
configure
(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject o) Does the auto completion for categories, matching with any category already present in the knowledge base.Does the auto completion for categories, matching with any category already present in the knowledge base.static String
The default icon to be used throughout this plugin.Get the categories that are considered generic.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
Returns the singleton instance.The knowledge base containing all causes.getKnowledgeBaseDescriptor
(String descString) Gets the KnowledgeBaseDescriptor that matches the name descString.Convenience method to reach the list from jelly.int
Returns the maximum log size that should be scanned.Getter for the no causes message.int
The number of threads to have in the pool for each build.Get configured slack channel.Get configured slack failure cause categories.Getter sodVariable.static String
Returns the base relative URI for static images packaged in webapp.static String
Returns the base relative URI for static resources packaged in webapp.Get categories to be assigned to failure causes representing failed test cases.boolean
If this feature is enabled or not.boolean
Send notifications to Gerrit-Trigger-plugin.boolean
If this feature is enabled or not.boolean
If graphs are enabled or not.boolean
If metrics should be squashed to only unique categories per build.boolean
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
Send notifications to Slack.boolean
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
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, configure, getDescriptor, getGlobalConfigPage
Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, doHelp, 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, getStaticHelpUrl, getStaticHelpUrl, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
Field Details
-
DEFAULT_ICON_SIZE
Convenience constant for the 24x24 icon size. used forgetImageUrl(String, String)
.- See Also:
-
DEFAULT_ICON_NAME
Convenience constant for the default icon size. used forgetImageUrl(String, String)
.- See Also:
-
DEFAULT_NR_OF_SCAN_THREADS
public static final int DEFAULT_NR_OF_SCAN_THREADSDefault number of concurrent scan threads.- See Also:
-
DEFAULT_MAX_LOG_SIZE
public static final int DEFAULT_MAX_LOG_SIZEDefault max size of log to be scanned ('0' disables check).- See Also:
-
DEFAULT_SLACK_CHANNEL
Default slack channel to use.- See Also:
-
DEFAULT_SLACK_FAILURE_CATEGORIES
Default value for which failure categories to notify slack.- See Also:
-
PERMISSION_GROUP
The permission group for all permissions related to this plugin. -
UPDATE_PERMISSION
Permission to update the causes. E.e. AccessCauseManagement
. -
VIEW_PERMISSION
Permission to view the causes. E.e. AccessCauseManagement
. -
REMOVE_PERMISSION
Permission to remove causes. -
MINIMUM_NR_OF_SCAN_THREADS
protected static final int MINIMUM_NR_OF_SCAN_THREADSMinimum allowed value fornrOfScanThreads
.- See Also:
-
-
Constructor Details
-
PluginImpl
@DataBoundConstructor public PluginImpl()Default constructor.
-
-
Method Details
-
readResolve
-
getConfigFile
- Overrides:
getConfigFile
in classDescriptor<GlobalConfiguration>
-
start
Starts the knowledge base. -
stop
Run on Jenkins shutdown. -
getStaticResourcesBase
Returns the base relative URI for static resources packaged in webapp.- Returns:
- the base URI.
-
getSodVariables
Getter sodVariable.- Returns:
- the message.
-
getStaticImagesBase
Returns the base relative URI for static images packaged in webapp.- Returns:
- the images directory.
- See Also:
-
getImageUrl
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
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
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:
-
getDefaultIcon
The default icon to be used throughout this plugin.- Returns:
- the relative URL to the image.
- See Also:
-
getInstance
Returns the singleton instance.- Returns:
- the one.
-
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
Sets the no causes message.- Parameters:
noCausesMessage
- the no causes message
-
setKnowledgeBase
Sets the knowledge base.- Parameters:
knowledgeBase
- the knowledge base
-
setSodVariables
Sets the scan on demand variables.- Parameters:
sodVariables
- the variables
-
setFallbackCategoriesAsString
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
Fallback categories.- Returns:
- Fallback categories
-
isTestResultParsingEnabled
public boolean isTestResultParsingEnabled()If failed test cases should be represented as failure causes.- Returns:
- True if enabled.
-
getTestResultCategories
Get categories to be assigned to failure causes representing failed test cases.- Returns:
- the categories.
-
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
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
Get configured slack channel.- Returns:
- String - Slack Channel.
-
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
Set configured slack channel.- Parameters:
slackChannelName
- null = DEFAULT_SLACK_CHANNEL
-
setSlackFailureCategories
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
Checks if the build with certain result should be analyzed or not.- Parameters:
result
- the result- Returns:
- true if it should be analyzed.
-
shouldScan
Checks if the specified build should be scanned or not.- Parameters:
build
- the build- Returns:
- true if it should be scanned.
- See Also:
-
isSizeInLimit
Checks that log size is in limits.- Parameters:
build
- the build- Returns:
- true if size is in limit.
-
shouldScan
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
The knowledge base containing all causes.- Returns:
- all the base.
-
getKnowledgeBaseDescriptors
Convenience method to reach the list from jelly.- Returns:
- the list of registered KnowledgeBaseDescriptors
-
getKnowledgeBaseDescriptor
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
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.
-