2016-04-22 21:56:07 +02:00
|
|
|
#!groovy
|
2016-08-22 04:18:07 +02:00
|
|
|
|
2019-04-10 21:05:02 +02:00
|
|
|
def buildImage = { String baseImage ->
|
|
|
|
def image
|
2016-11-15 02:23:25 +01:00
|
|
|
wrappedNode(label: "ubuntu && !zfs", cleanWorkspace: true) {
|
2019-04-10 21:05:02 +02:00
|
|
|
stage("build image for \"${baseImage}\"") {
|
2016-11-03 21:59:56 +01:00
|
|
|
checkout(scm)
|
2019-04-10 21:05:02 +02:00
|
|
|
def imageName = "dockerbuildbot/compose:${baseImage}-${gitCommit()}"
|
2016-04-22 21:56:07 +02:00
|
|
|
image = docker.image(imageName)
|
|
|
|
try {
|
|
|
|
image.pull()
|
|
|
|
} catch (Exception exc) {
|
2019-04-12 18:46:06 +02:00
|
|
|
sh """GIT_COMMIT=\$(script/build/write-git-sha) && \\
|
|
|
|
docker build -t ${imageName} \\
|
|
|
|
--target build \\
|
|
|
|
--build-arg BUILD_PLATFORM="${baseImage}" \\
|
|
|
|
--build-arg GIT_COMMIT="${GIT_COMMIT}" \\
|
|
|
|
.\\
|
|
|
|
"""
|
2019-04-10 21:05:02 +02:00
|
|
|
sh "docker push ${imageName}"
|
|
|
|
echo "${imageName}"
|
|
|
|
return imageName
|
2016-04-22 21:56:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-10 21:05:02 +02:00
|
|
|
echo "image.id: ${image.id}"
|
|
|
|
return image.id
|
2016-08-22 04:18:07 +02:00
|
|
|
}
|
2016-04-22 21:56:07 +02:00
|
|
|
|
2019-04-10 21:05:02 +02:00
|
|
|
def get_versions = { String imageId, int number ->
|
2018-02-03 01:24:17 +01:00
|
|
|
def docker_versions
|
|
|
|
wrappedNode(label: "ubuntu && !zfs") {
|
|
|
|
def result = sh(script: """docker run --rm \\
|
|
|
|
--entrypoint=/code/.tox/py27/bin/python \\
|
2019-04-10 21:05:02 +02:00
|
|
|
${imageId} \\
|
2018-02-03 01:24:17 +01:00
|
|
|
/code/script/test/versions.py -n ${number} docker/docker-ce recent
|
|
|
|
""", returnStdout: true
|
|
|
|
)
|
|
|
|
docker_versions = result.split()
|
|
|
|
}
|
|
|
|
return docker_versions
|
|
|
|
}
|
|
|
|
|
2016-04-22 21:56:07 +02:00
|
|
|
def runTests = { Map settings ->
|
|
|
|
def dockerVersions = settings.get("dockerVersions", null)
|
|
|
|
def pythonVersions = settings.get("pythonVersions", null)
|
2019-04-10 21:05:02 +02:00
|
|
|
def baseImage = settings.get("baseImage", null)
|
|
|
|
def imageName = settings.get("image", null)
|
2016-04-22 21:56:07 +02:00
|
|
|
|
|
|
|
if (!pythonVersions) {
|
2019-02-14 12:08:00 +01:00
|
|
|
throw new Exception("Need Python versions to test. e.g.: `runTests(pythonVersions: 'py27,py37')`")
|
2016-04-22 21:56:07 +02:00
|
|
|
}
|
|
|
|
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) {
|
2019-04-10 21:05:02 +02:00
|
|
|
stage("test python=${pythonVersions} / docker=${dockerVersions} / baseImage=${baseImage}") {
|
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" \\
|
2019-04-10 21:05:02 +02:00
|
|
|
-e "TAG=${imageName}" \\
|
2016-04-22 21:56:07 +02:00
|
|
|
-e "STORAGE_DRIVER=${storageDriver}" \\
|
|
|
|
-e "DOCKER_VERSIONS=${dockerVersions}" \\
|
|
|
|
-e "BUILD_NUMBER=\$BUILD_TAG" \\
|
|
|
|
-e "PY_TEST_VERSIONS=${pythonVersions}" \\
|
2018-02-03 01:24:17 +01:00
|
|
|
--entrypoint="script/test/ci" \\
|
2019-04-10 21:05:02 +02:00
|
|
|
${imageName} \\
|
2016-04-22 21:56:07 +02:00
|
|
|
--verbose
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-03 01:24:17 +01:00
|
|
|
def testMatrix = [failFast: true]
|
2019-04-10 21:05:02 +02:00
|
|
|
def baseImages = ['alpine', 'debian']
|
|
|
|
def pythonVersions = ['py27', 'py37']
|
|
|
|
baseImages.each { baseImage ->
|
|
|
|
def imageName = buildImage(baseImage)
|
|
|
|
get_versions(imageName, 2).each { dockerVersion ->
|
|
|
|
pythonVersions.each { pyVersion ->
|
|
|
|
testMatrix["${baseImage}_${dockerVersion}_${pyVersion}"] = runTests([baseImage: baseImage, image: imageName, dockerVersions: dockerVersion, pythonVersions: pyVersion])
|
|
|
|
}
|
|
|
|
}
|
2018-02-03 01:24:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
parallel(testMatrix)
|