Package io.jenkins.plugins.casc
Class ConfigurationAsCode
- java.lang.Object
-
- hudson.model.ManagementLink
-
- io.jenkins.plugins.casc.ConfigurationAsCode
-
- All Implemented Interfaces:
ExtensionPoint
,Action
,ModelObject
@Extension public class ConfigurationAsCode extends ManagementLink
- Author:
- Nicolas De Loof
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.ManagementLink
ManagementLink.Category
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static String
CASC_JENKINS_CONFIG_ENV
static String
CASC_JENKINS_CONFIG_PROPERTY
static String
DEFAULT_JENKINS_YAML_PATH
static String
YAML_FILES_PATTERN
-
Fields inherited from class hudson.model.ManagementLink
LIST
-
-
Constructor Summary
Constructors Constructor Description ConfigurationAsCode()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Source,String>
checkWith(Mapping entries, ConfigurationContext context)
Map<Source,String>
checkWith(YamlSource source)
List<Path>
configs(String path)
Recursive search for allYAML_FILES_PATTERN
in provided base pathvoid
configure()
Main entry point to start configuration process.void
configure(String... configParameters)
void
configure(Collection<String> configParameters)
void
configureWith(YamlSource source)
void
doApply(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res)
void
doCheck(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res)
FormValidation
doCheckNewSource(String newSource)
void
doExport(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res)
Export live jenkins instance configuration as Yamlvoid
doReference(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res)
void
doReload(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
void
doReplace(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
void
doSchema(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res)
Export JSONSchema to URLvoid
doViewExport(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res)
void
export(OutputStream out)
static ConfigurationAsCode
get()
List<String>
getBundledCasCURIs()
String
getCategoryName()
Name of the category for this management link.Collection<?>
getConfigurators()
Used for documentation generation in index.jellyString
getDescription()
String
getDisplayName()
String
getExtensionSource(Configurator c)
Retrieve which plugin do provide this extension point, used in documentation.jellyString
getHtmlHelp(Class type, String attribute)
Retrieve the html help tip associated to an attribute, used in documentation.jelly FIXME would prefer <st:include page="help-${a.name}.html" class="${c.target}" optional="true"/>String
getIconFileName()
Date
getLastTimeLoaded()
io.jenkins.plugins.prism.PrismConfiguration
getPrismConfiguration()
Permission
getRequiredPermission()
Collection<?>
getRootConfigurators()
Used for documentation generation in index.jellyList<String>
getSources()
String
getUrlName()
static void
handleExceptionOnReloading(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response, ConfiguratorException cause)
static void
init()
Defaults to use a file in the current working directory with the name 'jenkins.yaml' Add the environment variable CASC_JENKINS_CONFIG to override the default.static boolean
isSupportedURI(String configurationParameter)
static String
printThrowable(Throwable t)
static void
serializeYamlNode(org.yaml.snakeyaml.nodes.Node root, Writer writer)
org.yaml.snakeyaml.nodes.Node
toYaml(CNode config)
-
Methods inherited from class hudson.model.ManagementLink
all, getBadge, getCategory, getRequiresConfirmation, getRequiresPOST
-
-
-
-
Field Detail
-
CASC_JENKINS_CONFIG_PROPERTY
public static final String CASC_JENKINS_CONFIG_PROPERTY
- See Also:
- Constant Field Values
-
CASC_JENKINS_CONFIG_ENV
public static final String CASC_JENKINS_CONFIG_ENV
- See Also:
- Constant Field Values
-
DEFAULT_JENKINS_YAML_PATH
public static final String DEFAULT_JENKINS_YAML_PATH
- See Also:
- Constant Field Values
-
YAML_FILES_PATTERN
public static final String YAML_FILES_PATTERN
- See Also:
- Constant Field Values
-
-
Method Detail
-
getIconFileName
@CheckForNull public String getIconFileName()
- Specified by:
getIconFileName
in interfaceAction
- Specified by:
getIconFileName
in classManagementLink
-
getDisplayName
@CheckForNull public String getDisplayName()
-
getUrlName
@CheckForNull public String getUrlName()
- Specified by:
getUrlName
in interfaceAction
- Specified by:
getUrlName
in classManagementLink
-
getDescription
public String getDescription()
- Overrides:
getDescription
in classManagementLink
-
getCategoryName
@NonNull public String getCategoryName()
Name of the category for this management link. TODO: Use getCategory when core requirement is greater or equal to 2.226- Overrides:
getCategoryName
in classManagementLink
-
getRequiredPermission
@NonNull public Permission getRequiredPermission()
- Overrides:
getRequiredPermission
in classManagementLink
-
getLastTimeLoaded
public Date getLastTimeLoaded()
-
doReload
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doReload(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
- Throws:
Exception
-
handleExceptionOnReloading
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void handleExceptionOnReloading(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response, ConfiguratorException cause) throws javax.servlet.ServletException, IOException
- Throws:
javax.servlet.ServletException
IOException
-
doReplace
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doReplace(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
- Throws:
Exception
-
doCheckNewSource
@POST @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public FormValidation doCheckNewSource(@QueryParameter String newSource)
-
init
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @Initializer(after=SYSTEM_CONFIG_LOADED, before=SYSTEM_CONFIG_ADAPTED) public static void init() throws Exception
Defaults to use a file in the current working directory with the name 'jenkins.yaml' Add the environment variable CASC_JENKINS_CONFIG to override the default. Accepts single file or a directory. If a directory is detected, we scan for all .yml and .yaml files- Throws:
Exception
- when the file provided cannot be found or parsed
-
configure
public void configure() throws ConfiguratorException
Main entry point to start configuration process.- Throws:
ConfiguratorException
- Configuration error
-
getBundledCasCURIs
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<String> getBundledCasCURIs()
-
doCheck
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doCheck(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res) throws Exception
- Throws:
Exception
-
doApply
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doApply(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res) throws Exception
- Throws:
Exception
-
doExport
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doExport(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res) throws Exception
Export live jenkins instance configuration as Yaml- Throws:
Exception
-
doSchema
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doSchema(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res) throws Exception
Export JSONSchema to URL- Throws:
Exception
-
doViewExport
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doViewExport(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res) throws Exception
- Throws:
Exception
-
getPrismConfiguration
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public io.jenkins.plugins.prism.PrismConfiguration getPrismConfiguration()
-
doReference
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void doReference(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse res) throws Exception
- Throws:
Exception
-
export
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void export(OutputStream out) throws Exception
- Throws:
Exception
-
serializeYamlNode
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void serializeYamlNode(org.yaml.snakeyaml.nodes.Node root, Writer writer) throws IOException
- Throws:
IOException
-
toYaml
@CheckForNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.yaml.snakeyaml.nodes.Node toYaml(CNode config) throws ConfiguratorException
- Throws:
ConfiguratorException
-
configure
public void configure(String... configParameters) throws ConfiguratorException
- Throws:
ConfiguratorException
-
configure
public void configure(Collection<String> configParameters) throws ConfiguratorException
- Throws:
ConfiguratorException
-
isSupportedURI
public static boolean isSupportedURI(String configurationParameter)
-
configureWith
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void configureWith(YamlSource source) throws ConfiguratorException
- Throws:
ConfiguratorException
-
checkWith
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public Map<Source,String> checkWith(YamlSource source) throws ConfiguratorException
- Throws:
ConfiguratorException
-
configs
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<Path> configs(String path) throws ConfiguratorException
Recursive search for allYAML_FILES_PATTERN
in provided base path- Parameters:
path
- base path to start (can be file or directory)- Returns:
- list of all paths matching pattern. Only base file itself if it is a file matching pattern
- Throws:
ConfiguratorException
-
checkWith
public Map<Source,String> checkWith(Mapping entries, ConfigurationContext context) throws ConfiguratorException
- Throws:
ConfiguratorException
-
get
public static ConfigurationAsCode get()
-
getRootConfigurators
public Collection<?> getRootConfigurators()
Used for documentation generation in index.jelly
-
getConfigurators
public Collection<?> getConfigurators()
Used for documentation generation in index.jelly
-
getHtmlHelp
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public String getHtmlHelp(Class type, String attribute) throws IOException
Retrieve the html help tip associated to an attribute, used in documentation.jelly FIXME would prefer <st:include page="help-${a.name}.html" class="${c.target}" optional="true"/>- Parameters:
attribute
- to get help for- Returns:
- String that shows help. May be empty
- Throws:
IOException
- if the resource cannot be read
-
getExtensionSource
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) @CheckForNull public String getExtensionSource(Configurator c) throws IOException
Retrieve which plugin do provide this extension point, used in documentation.jelly- Returns:
- String representation of the extension source, usually artifactId.
- Throws:
IOException
-
-