A tutorial on building secure services via continuous delivery. Cheap.
First thing, before writing any code, is to set up the build environment so we can build, test and deploy the code on a local machine in an automation fashion. I have chosen to use gradle because:
By the time we’re done, the code should be structured as follows:
gradle/
wrapper/
gradle-wrapper.jar
gradle-wrapper.properties
.gitignore
build.gradle
gradlew
gradlew.bat
settings.gradle
I won’t go into any great detail on the gradle wrapper classes. If you want to learn more about those, and why they are there, please read up on gradle on the gradle docs pages. Suffice it to say that for a continuous integration project, it’s better to have the the build resources within the project than counting on what exists on the file system of the machine running the build.
The most interesting file is the build.gradle:
apply plugin: 'groovy'
sourceCompatibility = 1.8
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.+'
}
test {
exclude '**/*UATest.*'
}
task uat (type: Test, dependsOn:'test') {
include '**/*UATest.*'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
It’s all pretty standard gradle stuff except:
I have added the additional uat
target so I can run unit tests (via ./gradlew test
) and user acceptance tests (via ./gradlew uat
) separately. If we run the tests now, it will work but the results will be less than thrilling since there isn’t any code at this point.
Speaking of which, as good TDD developers, the next thing we’re going to do is write a test that exercises our first use case.
Source code for this section can be cloned from GitHub with the command:
git clone https://github.com/danielsomerfield/apigee-tutorial.git
git checkout write-your-service