2016-04-22 21:56:07 +02:00
|
|
|
#!groovy
|
2016-08-22 04:18:07 +02:00
|
|
|
|
2020-11-04 16:22:39 +01:00
|
|
|
def dockerVersions = ['19.03.13']
|
2019-12-04 08:43:28 +01:00
|
|
|
def baseImages = ['alpine', 'debian']
|
2021-01-22 11:14:55 +01:00
|
|
|
def pythonVersions = ['py37']
|
2019-12-04 08:43:28 +01:00
|
|
|
|
2019-12-03 16:47:52 +01:00
|
|
|
pipeline {
|
|
|
|
agent none
|
|
|
|
|
|
|
|
options {
|
|
|
|
skipDefaultCheckout(true)
|
|
|
|
buildDiscarder(logRotator(daysToKeepStr: '30'))
|
|
|
|
timeout(time: 2, unit: 'HOURS')
|
|
|
|
timestamps()
|
|
|
|
}
|
2020-10-20 17:53:47 +02:00
|
|
|
environment {
|
|
|
|
DOCKER_BUILDKIT="1"
|
|
|
|
}
|
2019-12-03 16:47:52 +01:00
|
|
|
|
|
|
|
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 {
|
2021-02-18 16:24:04 +01:00
|
|
|
label 'ubuntu-2004 && amd64 && !zfs && cgroup1'
|
2019-12-03 16:47:52 +01:00
|
|
|
}
|
|
|
|
steps {
|
|
|
|
buildImage('alpine')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('debian') {
|
|
|
|
agent {
|
2021-02-18 16:24:04 +01:00
|
|
|
label 'ubuntu-2004 && amd64 && !zfs && cgroup1'
|
2019-12-03 16:47:52 +01:00
|
|
|
}
|
|
|
|
steps {
|
|
|
|
buildImage('debian')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-04 09:40:33 +01:00
|
|
|
stage('Test') {
|
2019-12-04 08:43:28 +01:00
|
|
|
steps {
|
2019-12-04 10:33:54 +01:00
|
|
|
// TODO use declarative 1.5.0 `matrix` once available on CI
|
2019-12-04 08:43:28 +01:00
|
|
|
script {
|
2019-12-04 09:40:33 +01:00
|
|
|
def testMatrix = [:]
|
|
|
|
baseImages.each { baseImage ->
|
|
|
|
dockerVersions.each { dockerVersion ->
|
|
|
|
pythonVersions.each { pythonVersion ->
|
|
|
|
testMatrix["${baseImage}_${dockerVersion}_${pythonVersion}"] = runTests(dockerVersion, pythonVersion, baseImage)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
parallel testMatrix
|
2019-12-04 08:43:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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)
|
2021-02-10 15:06:06 +01:00
|
|
|
def imageName = "dockerpinata/compose:${baseImage}-${scmvar.GIT_COMMIT}"
|
2019-12-03 16:47:52 +01:00
|
|
|
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 \\
|
2020-10-20 17:53:47 +02:00
|
|
|
--build-arg DISTRO="${baseImage}" \\
|
2019-12-03 16:47:52 +01:00
|
|
|
--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-12-04 10:33:54 +01:00
|
|
|
return {
|
|
|
|
stage("python=${pythonVersion} docker=${dockerVersion} ${baseImage}") {
|
|
|
|
node("ubuntu && amd64 && !zfs") {
|
|
|
|
def scmvar = checkout(scm)
|
2021-02-10 15:06:06 +01:00
|
|
|
def imageName = "dockerpinata/compose:${baseImage}-${scmvar.GIT_COMMIT}"
|
2019-12-04 10:33:54 +01:00
|
|
|
def storageDriver = sh(script: "docker info -f \'{{.Driver}}\'", returnStdout: true).trim()
|
|
|
|
echo "Using local system's storage driver: ${storageDriver}"
|
|
|
|
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
|
|
|
|
sh """docker run \\
|
|
|
|
-t \\
|
|
|
|
--rm \\
|
|
|
|
--privileged \\
|
|
|
|
--volume="\$(pwd)/.git:/code/.git" \\
|
|
|
|
--volume="/var/run/docker.sock:/var/run/docker.sock" \\
|
2021-02-18 18:44:21 +01:00
|
|
|
--volume="\${DOCKER_CONFIG}/config.json:/root/.docker/config.json" \\
|
2021-01-28 10:50:01 +01:00
|
|
|
-e "DOCKER_TLS_CERTDIR=" \\
|
2019-12-04 10:33:54 +01:00
|
|
|
-e "TAG=${imageName}" \\
|
|
|
|
-e "STORAGE_DRIVER=${storageDriver}" \\
|
|
|
|
-e "DOCKER_VERSIONS=${dockerVersion}" \\
|
|
|
|
-e "BUILD_NUMBER=${env.BUILD_NUMBER}" \\
|
|
|
|
-e "PY_TEST_VERSIONS=${pythonVersion}" \\
|
|
|
|
--entrypoint="script/test/ci" \\
|
|
|
|
${imageName} \\
|
|
|
|
--verbose
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-22 21:56:07 +02:00
|
|
|
}
|
|
|
|
}
|