$ show jenkinsci/job-dsl-plugin
The Jenkins Job DSL Plugin is a mature, actively maintained Jenkins plugin that provides a Groovy-based domain-specific language for programmatically defining Jenkins jobs, views, folders, and other configuration items. It enables 'Configuration as Code' for Jenkins, allowing infrastructure to be version-controlled and automatically generated. The plugin executes as a build step in a seed job, parsing DSL scripts and creating or updating Jenkins items. The architecture consists of a core library (`job-dsl-core`) with hundreds of context classes that map DSL method calls to XML configuration nodes, and a Jenkins plugin module (`job-dsl-plugin`) that integrates with the Jenkins API for script execution, security, and result tracking. The plugin supports all major Jenkins job types (freestyle, pipeline, multibranch, matrix, etc.), SCM integrations, build triggers, wrappers, publishers, and parameterized builds. A notable feature is the Dynamic DSL, which automatically discovers and exposes methods for any Jenkins plugin that follows the Describable pattern, reducing the need for built-in methods. The codebase is extensive with thorough Spock tests, but is tightly coupled to specific Jenkins plugin versions and Groovy 2.4, and the built-in DSL is in maintenance mode in favor of the Dynamic DSL. The repository includes a web-based API viewer and comprehensive documentation for migration and scripting.
The LLM identified 3 files worth highlighting for reuse:
A Groovy AST transformation that adds @DelegatesTo annotations to DSL closure parameters, enabling IDE autocompletion and compile-time checks. It processes @DslContext annotations on closure parameters and generates the appropriate delegate type hints. This component is self-contained (depends only on Groovy AST API) and demonstrates advanced Groovy metaprogramming, making it reusable for other DSL frameworks that want to provide IDE support.
A Groovy AST transformation that injects deprecation warnings into methods annotated with @Deprecated. It adds a logDeprecationWarning() call at the beginning of the method body, ensuring runtime deprecation notices are always emitted. This is a clean, reusable pattern for managing API deprecation in Groovy-based DSLs, and could be extracted to any project using AST transformations.
Provides runtime discovery and indexing of Jenkins DescribableModel instances (from the Structs plugin), enabling the Dynamic DSL. It scans for all @Symbol-annotated Describables and creates method signatures that can be called in DSL scripts. This component is relatively self-contained (depends on Jenkins and Structs API) and demonstrates a robust pattern for dynamically extending a DSL with third-party plugin capabilities. It could be reused in other Jenkins-related DSL projects.