use of jenkins.tools.ToolConfigurationCategory in project configuration-as-code-plugin by jenkinsci.
the class Util method getToolRoot.
/**
* Gets the "tool" root mapping.
* <p>
* Example usage:
* <pre>{@code
* ConfiguratorRegistry registry = ConfiguratorRegistry.get();
* ConfigurationContext context = new ConfigurationContext(registry);
* CNode configNode = getToolRoot(context).get("git");}</pre>
*
* @param context the configuration context
* @return the "tool" root mapping
* @throws Exception something's not right...
*/
public static Mapping getToolRoot(ConfigurationContext context) throws Exception {
ToolConfigurationCategory category = ExtensionList.lookup(ToolConfigurationCategory.class).get(0);
GlobalConfigurationCategoryConfigurator configurator = new GlobalConfigurationCategoryConfigurator(category);
return Objects.requireNonNull(configurator.describe(configurator.getTargetComponent(context), context)).asMapping();
}
Aggregations