jenkins-plugin-cli --plugins structs:337.v1b_04ea_4df7c8
Structs
Library plugin for DSL plugins that need concise names for Jenkins extensions.
What is Structs Plugin?
Jenkins features several DSL (Domain-Specific Language) plugins, like the Job DSL and Pipeline plugins. These plugins simplify referencing Jenkins objects and extension points by using short, consistent names.
The cool part is how plugin developers can define these names. They use the @Symbol
annotation to assign a memorable and concise name to each extension. This name is then used across all DSL plugins, which not only ensures consistency but also makes scripts easier to understand and maintain.
This is super helpful because it means less guesswork for us when scripting and better coherence across our Jenkins environment.
Jenkins has many DSL like plugins that require having short concise names for implementations of the extension points and other Jenkins objects. For example, Job DSL Plugin refers to each SCM
extension by its short name. The same goes for pipeline plugin.
It benefits users that these DSL plugins use consistent names. This plugin, together with the @Symbol
annotation, allow plugin developers to name their extension and have all the DSL plugins recognize them.
How to use Structs Plugin?
To achieve this, you place the @Symbol annotation alongside your @Extension. The symbol name should be a valid Java identifier—short and concise to ease use and recall. Importantly, it only needs to be unique within its extension point. For instance, both GitSCM and GitToolInstaller might use the symbol name "git" because they belong to different extension points. Here's a snippet to illustrate:
public class GitSCM {
@Extension @Symbol("git")
public static class DescriptorImpl extends SCMDescriptor {
// implementation details
}
}
Additionally, if your plugin targets Jenkins version 1.x, you'll need to include the structs plugin as a dependency in your plugin's POM file:
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.2</version>
</dependency>
This setup helps maintain compatibility with older DSL plugins that might predate the structs plugin, even if some extensions might carry legacy names that don’t follow this convention.
Monitoring GitHub Actions Workflows
CICube is a GitHub Actions monitoring tool that provides you with detailed insights into your workflows to further optimize your CI/CD pipeline. With CICube, you will be able to track your workflow runs, understand where the bottlenecks are, and tease out the best from your build times. Go to cicube.io now and create a free account to better optimize your GitHub Actions workflows!