Domain Specific Languages
Language capabilities
The Jenkins Pipeline DSL is used as an example for such a language:
node {
git 'https://github.com/joe_user/simple-maven-project-with-tests.git'
def mvnHome = tool 'M3'
sh "${mvnHome}/bin/mvn -B -Dmaven.test.failure.ignore verify"
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
junit '**/target/surefire-reports/TEST-*.xml'
}
The purpose of this DSL is the define and execute Jenkins build jobs (or better pipelines) in a more natural language.
Writing a domain specific language in Groovy benefits by Groovy’s core features like:
- Optionality (e.g. omit parentheses)
- Operator overloading
- Meta programming (e.g. resolving missing properties or methods)
- Closures and delegation strategies
- Compiler customization
- Scripting support and integration capabilities