2016-04-22 21:56:07 +02:00
|
|
|
#!groovy
|
2016-08-22 04:18:07 +02:00
|
|
|
|
2019-12-04 08:43:28 +01:00
|
|
|
def dockerVersions
|
|
|
|
def baseImages = ['alpine', 'debian']
|
|
|
|
def pythonVersions = ['py27', 'py37']
|
|
|
|
|
2019-12-03 16:47:52 +01:00
|
|
|
pipeline {
|
|
|
|
agent none
|
|
|
|
|
|
|
|
options {
|
|
|
|
skipDefaultCheckout(true)
|
|
|
|
buildDiscarder(logRotator(daysToKeepStr: '30'))
|
|
|
|
timeout(time: 2, unit: 'HOURS')
|
|
|
|
timestamps()
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
TAG = tag()
|
|
|
|
BUILD_TAG = tag()
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Build test images') {
|
2019-12-04 08:43:28 +01:00
|
|
|
// TODO use declarative 1.5.0 `matrix` once available on CI
|
2019-12-03 16:47:52 +01:00
|
|
|
parallel {
|
|
|
|
stage('alpine') {
|
|
|
|
agent {
|
|
|
|
label 'ubuntu && amd64 && !zfs'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
buildImage('alpine')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('debian') {
|
|
|
|
agent {
|
|
|
|
label 'ubuntu && amd64 && !zfs'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
buildImage('debian')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-04 08:43:28 +01:00
|
|
|
stage('Get Docker versions') {
|
|
|
|
agent {
|
|
|
|
label 'ubuntu'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
dockerVersions = sh(script:"""
|
|
|
|
curl https://api.github.com/repos/docker/docker-ce/releases \
|
|
|
|
| jq -r -c '.[] | select (.prerelease == false ) | .tag_name | ltrimstr("v")' > /tmp/versions.txt
|
|
|
|
for v in \$(cut -f1 -d"." /tmp/versions.txt | uniq | head -2); do grep -m 1 "\$v" /tmp/versions.txt ; done
|
|
|
|
""", returnStdout: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-03 16:47:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-03 13:45:05 +01:00
|
|
|
def buildImage(baseImage) {
|
2019-12-03 16:47:52 +01:00
|
|
|
def scmvar = checkout(scm)
|
|
|
|
def imageName = "dockerbuildbot/compose:${baseImage}-${scmvar.GIT_COMMIT}"
|
|
|
|
image = docker.image(imageName)
|
|
|
|
|
|
|
|
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
|
|
|
|
try {
|
|
|
|
image.pull()
|
|
|
|
} catch (Exception exc) {
|
|
|
|
ansiColor('xterm') {
|
|
|
|
sh """docker build -t ${imageName} \\
|
|
|
|
--target build \\
|
|
|
|
--build-arg BUILD_PLATFORM="${baseImage}" \\
|
|
|
|
--build-arg GIT_COMMIT="${scmvar.GIT_COMMIT}" \\
|
|
|
|
.\\
|
|
|
|
"""
|
|
|
|
sh "docker push ${imageName}"
|
|
|
|
}
|
|
|
|
echo "${imageName}"
|
|
|
|
return imageName
|
|
|
|
}
|
2016-04-22 21:56:07 +02:00
|
|
|
}
|
2016-08-22 04:18:07 +02:00
|
|
|
}
|
2016-04-22 21:56:07 +02:00
|
|
|
|
2019-12-04 08:43:28 +01:00
|
|
|
def runTests(dockerVersion, pythonVersion, baseImage) {
|
2019-10-14 21:17:15 +02:00
|
|
|
wrappedNode(label: "ubuntu && amd64 && !zfs", cleanWorkspace: true) {
|
2019-12-04 08:43:28 +01:00
|
|
|
stage("test python=${pythonVersion} / docker=${dockerVersion} / baseImage=${baseImage}") {
|
2019-12-03 16:47:52 +01:00
|
|
|
def scmvar = checkout(scm)
|
|
|
|
def imageName = "dockerbuildbot/compose:${baseImage}-${scmvar.GIT_COMMIT}"
|
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}" \\
|
2019-12-04 08:43:28 +01:00
|
|
|
-e "DOCKER_VERSIONS=${dockerVersion}" \\
|
2016-04-22 21:56:07 +02:00
|
|
|
-e "BUILD_NUMBER=\$BUILD_TAG" \\
|
2019-12-04 08:43:28 +01:00
|
|
|
-e "PY_TEST_VERSIONS=${pythonVersion}" \\
|
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
|
|
|
|
"""
|
2019-12-04 08:43:28 +01:00
|
|
|
}
|
2016-04-22 21:56:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-03 01:24:17 +01:00
|
|
|
def testMatrix = [failFast: true]
|
2019-12-04 08:43:28 +01:00
|
|
|
|
2019-04-10 21:05:02 +02:00
|
|
|
baseImages.each { baseImage ->
|
2019-12-04 08:43:28 +01:00
|
|
|
dockerVersions.eachLine { dockerVersion ->
|
|
|
|
pythonVersions.each { pythonVersion ->
|
|
|
|
testMatrix["${baseImage}_${dockerVersion}_${pythonVersion}"] = runTests(dockerVersion, pythonVersion, baseImage)
|
|
|
|
}
|
2019-04-10 21:05:02 +02:00
|
|
|
}
|
2018-02-03 01:24:17 +01:00
|
|
|
}
|
|
|
|
|
2019-12-04 08:43:28 +01:00
|
|
|
parallel testMatrix
|