A Groovy DSL for writing Bamboo Specs. Configuration as code, made simple.
Note: This project is still very much in the experimental stage. Contribution by way of ideas, suggestions and pull requests is very welcome. The plan is to get the API to a stable point and release version 1.0 as soon as possible.
Usage examples will be written once the examples from Bamboo's documentation are fully implemented.
To start using the library, add it to your project using Groovy's @Grab
(the
simplest way to get started), or Gradle or Maven for more advanced build
configurations. The library is available through Bintray's JCenter.
@Grab('com.thecodesmith.bamboo:bamboo-specs-dsl:0.10.3')
compile 'com.thecodesmith.bamboo:bamboo-specs-dsl:0.10.3'
<dependency>
<groupId>com.thecodesmith.bamboo</groupId>
<artifactId>bamboo-specs-dsl</artifactId>
<version>0.10.3</version>
</dependency>
- Groovy is required to post plan definition to Bamboo. It can be installed easily with SDKMAN!:
curl -s "https://get.sdkman.io" | bash
sdk install groovy
- IntelliJ IDEA or another IDE is helpful for code completion, but a text editor works just fine
Create a Groovy script, for example named BambooPlan.groovy
:
@Grab('com.thecodesmith.bamboo:bamboo-specs-dsl:0.10.3')
import com.thecodesmith.bamboo.specs.dsl.ProjectDsl
import com.thecodesmith.bamboo.specs.dsl.PlanDsl
project = ProjectDsl.project('foo', 'FOO') {
description 'Project description here'
}
plan = PlanDsl.plan(project, 'bar', 'BAR') {
description 'Build and test the project'
planRepositories {
gitRepository {
name 'my-repo'
url 'ssh://[email protected]:my-company/my-repo.git'
}
}
stage('Build') {
job('Build WAR', 'WAR') {
tasks {
mavenTask {
goal 'clean package'
jdk 'JDK 1.8'
version3()
executionLabel 'Maven 3.2'
hasTests true
testResultsPath '**/target/reports/*.xml'
}
}
}
}
}
Add this to the bottom of the definition script:
BAMBOO_URL = 'https://bamboo.my-company.com'
BAMBOO_CREDENTIALS = new FileUserPasswordCredentials()
server = new BambooServer(BAMBOO_URL, BAMBOO_CREDENTIALS)
server.publish(plan)
This code could be extracted to a separate file if needed to run multiple plan definitions.
Then run the script:
groovy BambooPlan.groovy
This line can be used to print the generated YAML for a Plan definition:
println BambooSpecSerializer.dump(plan)
Enable debug logging for the Bamboo Specs library by running with system
property -Dbamboo.specs.log.level=DEBUG
.
The DSL currently supports all features listed in the Bamboo Specs official documentation. If you find any missing features, please let me know by opening an issue.
Pull requests are welcome! If there is a feature that is not yet implemented, create a pull request and I will work to get it merged into the project. Reporting issues is a big help as well.
This library is licensed under the terms of the Apache License, Version 2.0.