2016-04-22 21:56:07 +02:00
|
|
|
#!groovy
|
2016-08-22 04:18:07 +02:00
|
|
|
|
2016-04-22 21:56:07 +02:00
|
|
|
def image
|
|
|
|
|
|
|
|
def buildImage = { ->
|
2016-11-15 02:23:25 +01:00
|
|
|
wrappedNode(label: "ubuntu && !zfs", cleanWorkspace: true) {
|
2016-04-22 21:56:07 +02:00
|
|
|
stage("build image") {
|
2016-11-03 21:59:56 +01:00
|
|
|
checkout(scm)
|
2016-04-22 21:56:07 +02:00
|
|
|
def imageName = "dockerbuildbot/compose:${gitCommit()}"
|
|
|
|
image = docker.image(imageName)
|
|
|
|
try {
|
|
|
|
image.pull()
|
|
|
|
} catch (Exception exc) {
|
|
|
|
image = docker.build(imageName, ".")
|
|
|
|
image.push()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-22 04:18:07 +02:00
|
|
|
}
|
2016-04-22 21:56:07 +02:00
|
|
|
|
|
|
|
def runTests = { Map settings ->
|
|
|
|
def dockerVersions = settings.get("dockerVersions", null)
|
|
|
|
def pythonVersions = settings.get("pythonVersions", null)
|
|
|
|
|
|
|
|
if (!pythonVersions) {
|
|
|
|
throw new Exception("Need Python versions to test. e.g.: `runTests(pythonVersions: 'py27,py34')`")
|
|
|
|
}
|
|
|
|
if (!dockerVersions) {
|
|
|
|
throw new Exception("Need Docker versions to test. e.g.: `runTests(dockerVersions: 'all')`")
|
|
|
|
}
|
|
|
|
|
|
|
|
{ ->
|
2016-11-15 02:23:25 +01:00
|
|
|
wrappedNode(label: "ubuntu && !zfs", cleanWorkspace: true) {
|
2016-04-22 21:56:07 +02:00
|
|
|
stage("test python=${pythonVersions} / docker=${dockerVersions}") {
|
2016-11-03 21:59:56 +01:00
|
|
|
checkout(scm)
|
2016-04-22 21:56:07 +02:00
|
|
|
def storageDriver = sh(script: 'docker info | awk -F \': \' \'$1 == "Storage Driver" { print $2; exit }\'', returnStdout: true).trim()
|
|
|
|
echo "Using local system's storage driver: ${storageDriver}"
|
|
|
|
sh """docker run \\
|
|
|
|
-t \\
|
|
|
|
--rm \\
|
|
|
|
--privileged \\
|
|
|
|
--volume="\$(pwd)/.git:/code/.git" \\
|
|
|
|
--volume="/var/run/docker.sock:/var/run/docker.sock" \\
|
|
|
|
-e "TAG=${image.id}" \\
|
|
|
|
-e "STORAGE_DRIVER=${storageDriver}" \\
|
|
|
|
-e "DOCKER_VERSIONS=${dockerVersions}" \\
|
|
|
|
-e "BUILD_NUMBER=\$BUILD_TAG" \\
|
|
|
|
-e "PY_TEST_VERSIONS=${pythonVersions}" \\
|
|
|
|
--entrypoint="script/ci" \\
|
|
|
|
${image.id} \\
|
|
|
|
--verbose
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-03 21:59:56 +01:00
|
|
|
buildImage()
|
|
|
|
// TODO: break this out into meaningful "DOCKER_VERSIONS" values instead of all
|
2016-04-22 21:56:07 +02:00
|
|
|
parallel(
|
2016-11-03 21:59:56 +01:00
|
|
|
failFast: true,
|
|
|
|
all_py27: runTests(pythonVersions: "py27", dockerVersions: "all"),
|
|
|
|
all_py34: runTests(pythonVersions: "py34", dockerVersions: "all"),
|
2016-04-22 21:56:07 +02:00
|
|
|
)
|