Package hudson.plugins.jobConfigHistory
Class JobConfigHistory
- java.lang.Object
-
- hudson.model.Descriptor<GlobalConfiguration>
-
- jenkins.model.GlobalConfiguration
-
- hudson.plugins.jobConfigHistory.JobConfigHistory
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<GlobalConfiguration>
,Saveable
,OnMaster
@Symbol("jobConfigHistory") @Extension public class JobConfigHistory extends GlobalConfiguration
Class supporting global configuration settings, along with methods associated with the plugin itself.- Author:
- John Borghi
-
-
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 protected static Permission
DELETEENTRY_PERMISSION
-
Fields inherited from class hudson.model.Descriptor
clazz
-
-
Constructor Summary
Constructors Constructor Description JobConfigHistory()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject formData)
FormValidation
doCheckExcludePattern(String value)
Validates the user entry for the regular expression of system file names to exclude from saving.FormValidation
doCheckMaxDaysToKeepEntries(String value)
Validates the user entry for the maximum number of days to keep history items.FormValidation
doCheckMaxEntriesPerPage(String value)
Validates the user entry for the maximum number of history items to show per page.FormValidation
doCheckMaxHistoryEntries(String value)
Validates the user entry for the maximum number of history items to keep.protected XmlFile
getConfigFile()
File
getConfigFile(File historyDir)
File
getConfiguredHistoryRootDir()
Returns the File object representing the configured root history directory.String
getDefaultRootDir()
Gets the default root directory for storing histories.String
getExcludedUsers()
Gets usernames whose changes should not get detected.String
getExcludePattern()
Gets the regular expression pattern for 'system' configuration files to exclude from saving.Pattern
getExcludeRegexpPattern()
Gets the regular expression pattern used by this class.protected HistoryDao
getHistoryDao()
For tests.String
getHistoryRootDir()
Gets the root directory for storing histories.Jenkins
getJenkins()
Deprecated.protected File
getJenkinsHome()
For tests.String
getMaxDaysToKeepEntries()
Gets the maximum number of days to keep history entries.String
getMaxEntriesPerPage()
Gets the maximum number of history entries to show per page.String
getMaxHistoryEntries()
Gets the maximum number of history entries to keep.boolean
getSaveItemGroupConfiguration()
Deprecated.since version 2.9boolean
getSaveModuleConfiguration()
Gets whether to save the config history of Maven modules.String
getShowBuildBadges()
Gets whether build badges should appear when the config of a job has changed since the last build.boolean
getShowChangeReasonCommentWindow()
Gets whether a change reason comment window should be shown on a jobs' configure page.boolean
getSkipDuplicateHistory()
Gets whether to skip saving history when it is a duplication of the previous saved configuration.boolean
isPositiveInteger(String numberString)
Checks if a string evaluates to a positive integer number.boolean
isSaveable(Saveable item, XmlFile xmlFile)
Returns true if configuration for this item should be saved, based on the plugin settings, the type of item and the configuration file specified.void
setExcludedUsers(String excludedUsers)
Sets usernames whose changes should not get detected.void
setExcludePattern(String excludePattern)
Sets the regular expression pattern for 'system' configuration files to exclude from saving.void
setHistoryRootDir(String historyRootDir)
Sets the root directory for storing histories.void
setMaxDaysToKeepEntries(String maxDaysInput)
Sets the maximum number of days to keep history entries.void
setMaxEntriesPerPage(String maxEntryInput)
Sets the maximum number of history entries to show per page.void
setMaxHistoryEntries(String maxEntryInput)
Sets the maximum number of history entries to keep.void
setSaveModuleConfiguration(boolean saveModuleConfiguration)
Sets whether to save the config history of Maven modules.void
setShowBuildBadges(String showBuildBadges)
Sets whether build badges should appear when the config of a job has changed since the last build.void
setShowChangeReasonCommentWindow(boolean showChangeReasonCommentWindow)
Sets whether a change reason comment window should be shown on a jobs' configure page.void
setSkipDuplicateHistory(boolean skipDuplicateHistory)
Sets whether to skip saving history when it is a duplication of the previous saved configuration.boolean
showBuildBadges(Job<?,?> project)
Whether build badges should appear for the builds of this project.-
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
-
DELETEENTRY_PERMISSION
protected static final Permission DELETEENTRY_PERMISSION
-
-
Method Detail
-
configure
public boolean configure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject formData) throws Descriptor.FormException
- Overrides:
configure
in classGlobalConfiguration
- Throws:
Descriptor.FormException
-
getConfigFile
protected XmlFile getConfigFile()
- Overrides:
getConfigFile
in classDescriptor<GlobalConfiguration>
-
getDefaultRootDir
public String getDefaultRootDir()
Gets the default root directory for storing histories.- Returns:
- The default root directory.
-
getHistoryRootDir
public String getHistoryRootDir()
Gets the root directory for storing histories.- Returns:
- The root directory.
-
setHistoryRootDir
@DataBoundSetter public void setHistoryRootDir(String historyRootDir)
Sets the root directory for storing histories.- Parameters:
historyRootDir
- The root directory.
-
getMaxHistoryEntries
public String getMaxHistoryEntries()
Gets the maximum number of history entries to keep.- Returns:
- The maximum number of history entries to keep.
-
setMaxHistoryEntries
@DataBoundSetter public void setMaxHistoryEntries(String maxEntryInput)
Sets the maximum number of history entries to keep.- Parameters:
maxEntryInput
- The maximum number of history entries to keep.
-
getMaxEntriesPerPage
public String getMaxEntriesPerPage()
Gets the maximum number of history entries to show per page.- Returns:
- The maximum number of history entries to show per page.
-
setMaxEntriesPerPage
@DataBoundSetter public void setMaxEntriesPerPage(String maxEntryInput)
Sets the maximum number of history entries to show per page.- Parameters:
maxEntryInput
- The maximum number of history entries to show per page.
-
getMaxDaysToKeepEntries
public String getMaxDaysToKeepEntries()
Gets the maximum number of days to keep history entries.- Returns:
- The maximum number of days to keep history entries.
-
setMaxDaysToKeepEntries
@DataBoundSetter public void setMaxDaysToKeepEntries(String maxDaysInput)
Sets the maximum number of days to keep history entries.- Parameters:
maxDaysInput
- The maximum number of days to keep history entries.
-
isPositiveInteger
public boolean isPositiveInteger(String numberString)
Checks if a string evaluates to a positive integer number.- Parameters:
numberString
- The number in question (as String)- Returns:
- Whether the number is a positive integer
-
getSaveItemGroupConfiguration
@Deprecated public boolean getSaveItemGroupConfiguration()
Deprecated.since version 2.9- Returns:
- True if item group configurations should be saved.
-
getSkipDuplicateHistory
public boolean getSkipDuplicateHistory()
Gets whether to skip saving history when it is a duplication of the previous saved configuration.- Returns:
- Whether to skip saving history when it is a duplication of the previous saved configuration.
-
setSkipDuplicateHistory
@DataBoundSetter public void setSkipDuplicateHistory(boolean skipDuplicateHistory)
Sets whether to skip saving history when it is a duplication of the previous saved configuration.- Parameters:
skipDuplicateHistory
- Whether to skip saving history when it is a duplication of the previous saved configuration.
-
getExcludePattern
public String getExcludePattern()
Gets the regular expression pattern for 'system' configuration files to exclude from saving.- Returns:
- The regular expression pattern.
-
setExcludePattern
@DataBoundSetter public void setExcludePattern(String excludePattern)
Sets the regular expression pattern for 'system' configuration files to exclude from saving.- Parameters:
excludePattern
- The regular expression pattern.
-
getSaveModuleConfiguration
public boolean getSaveModuleConfiguration()
Gets whether to save the config history of Maven modules.- Returns:
- Whether to save the config history of Maven modules.
-
setSaveModuleConfiguration
@DataBoundSetter public void setSaveModuleConfiguration(boolean saveModuleConfiguration)
Sets whether to save the config history of Maven modules.- Parameters:
saveModuleConfiguration
- Whether to save the config history of Maven modules.
-
getShowBuildBadges
public String getShowBuildBadges()
Gets whether build badges should appear when the config of a job has changed since the last build.- Returns:
- Possible value: "never", "always", "userWithConfigPermission", "adminUser"
-
setShowBuildBadges
@DataBoundSetter public void setShowBuildBadges(String showBuildBadges)
Sets whether build badges should appear when the config of a job has changed since the last build.- Parameters:
showBuildBadges
- Possible values: "never", "always", "userWithConfigPermission", "adminUser"
-
getShowChangeReasonCommentWindow
public boolean getShowChangeReasonCommentWindow()
Gets whether a change reason comment window should be shown on a jobs' configure page.- Returns:
- Whether a comment window should be shown.
-
setShowChangeReasonCommentWindow
@DataBoundSetter public void setShowChangeReasonCommentWindow(boolean showChangeReasonCommentWindow)
Sets whether a change reason comment window should be shown on a jobs' configure page.- Parameters:
showChangeReasonCommentWindow
- Whether a comment window should be shown.
-
showBuildBadges
public boolean showBuildBadges(Job<?,?> project)
Whether build badges should appear for the builds of this project.- Parameters:
project
- The project to which the build history belongs.- Returns:
- False if the option is set to 'never' or the user doesn't have the required permissions.
-
getExcludeRegexpPattern
public Pattern getExcludeRegexpPattern()
Gets the regular expression pattern used by this class.- Returns:
- The loaded regexp pattern, or null if pattern was invalid.
-
getConfiguredHistoryRootDir
public File getConfiguredHistoryRootDir()
Returns the File object representing the configured root history directory.- Returns:
- The configured root history File object. from the URI.
-
getConfigFile
public File getConfigFile(File historyDir)
- Parameters:
historyDir
- The history directory to look under.- Returns:
- The configuration file or null if no file is found.
- See Also:
FileHistoryDao.getConfigFile(java.io.File)
-
getExcludedUsers
public String getExcludedUsers()
Gets usernames whose changes should not get detected.- Returns:
- Comma separated list of usernames.
-
setExcludedUsers
@DataBoundSetter public void setExcludedUsers(String excludedUsers)
Sets usernames whose changes should not get detected.- Parameters:
excludedUsers
- Comma separated list of usernames.
-
isSaveable
public boolean isSaveable(Saveable item, XmlFile xmlFile)
Returns true if configuration for this item should be saved, based on the plugin settings, the type of item and the configuration file specified.If the item is an instance of
AbstractProject
or the configuration file is stored directly in JENKINS_ROOT, it is considered for saving.If the plugin is configured to skip saving duplicated history, we also evaluate if this configuration duplicates the previous saved history (if such history exists).
- Parameters:
item
- The item whose configuration is under consideration.xmlFile
- The configuration file for the above item.- Returns:
- true if the item configuration should be saved.
-
doCheckMaxHistoryEntries
public FormValidation doCheckMaxHistoryEntries(@QueryParameter String value)
Validates the user entry for the maximum number of history items to keep. Must be blank or a non-negative integer.- Parameters:
value
- The form input entered by the user.- Returns:
- ok if the entry is blank or a non-negative integer.
-
doCheckMaxEntriesPerPage
public FormValidation doCheckMaxEntriesPerPage(@QueryParameter String value)
Validates the user entry for the maximum number of history items to show per page. Must be blank or a non-negative integer.- Parameters:
value
- The form input entered by the user.- Returns:
- ok if the entry is blank or a non-negative integer.
-
doCheckMaxDaysToKeepEntries
public FormValidation doCheckMaxDaysToKeepEntries(@QueryParameter String value)
Validates the user entry for the maximum number of days to keep history items. Must be blank or a non-negative integer.- Parameters:
value
- The form input entered by the user.- Returns:
- ok if the entry is blank or a non-negative integer.
-
doCheckExcludePattern
public FormValidation doCheckExcludePattern(@QueryParameter String value)
Validates the user entry for the regular expression of system file names to exclude from saving.- Parameters:
value
- The form input entered by the user.- Returns:
- ok if the entry is a valid regular expression.
-
getHistoryDao
protected HistoryDao getHistoryDao()
For tests.- Returns:
- The history DAO.
-
getJenkinsHome
protected File getJenkinsHome()
For tests.- Returns:
- JENKINS_HOME
-
getJenkins
@Deprecated public Jenkins getJenkins()
Deprecated.For tests.- Returns:
- The Jenkins instance.
-
-