diff options
author | aiordache <anca.iordache@docker.com> | 2020-11-19 19:33:24 +0100 |
---|---|---|
committer | aiordache <anca.iordache@docker.com> | 2021-02-15 15:44:29 +0100 |
commit | da26073c75d60e0b6597070231bb408cff2ee83c (patch) | |
tree | 512cb4a0b92ba2b61a999ca1289f16f3c281502f | |
parent | c5022e1491c4df6da17f822b1d14f37f8b196ce9 (diff) | |
download | docker-py-da26073c75d60e0b6597070231bb408cff2ee83c.tar.gz |
Mount docker config to DIND containers for authentication
Signed-off-by: aiordache <anca.iordache@docker.com>
-rw-r--r-- | Jenkinsfile | 73 |
1 files changed, 38 insertions, 35 deletions
diff --git a/Jenkinsfile b/Jenkinsfile index b5ea7a4..4f97077 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -83,41 +83,44 @@ def runTests = { Map settings -> def dindContainerName = "dpy-dind-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}" def testContainerName = "dpy-tests-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}" def testNetwork = "dpy-testnet-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}" - try { - sh """docker network create ${testNetwork}""" - sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\ - ${imageDindSSH} dockerd -H tcp://0.0.0.0:2375 - """ - sh """docker run --rm \\ - --name ${testContainerName} \\ - -e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\ - -e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\ - --network ${testNetwork} \\ - --volumes-from ${dindContainerName} \\ - ${testImage} \\ - py.test -v -rxs --cov=docker --ignore=tests/ssh tests/ - """ - sh """docker stop ${dindContainerName}""" - - // start DIND container with SSH - sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\ - ${imageDindSSH} dockerd --experimental""" - sh """docker exec ${dindContainerName} sh -c /usr/sbin/sshd """ - // run SSH tests only - sh """docker run --rm \\ - --name ${testContainerName} \\ - -e "DOCKER_HOST=ssh://${dindContainerName}:22" \\ - -e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\ - --network ${testNetwork} \\ - --volumes-from ${dindContainerName} \\ - ${testImage} \\ - py.test -v -rxs --cov=docker tests/ssh - """ - } finally { - sh """ - docker stop ${dindContainerName} - docker network rm ${testNetwork} - """ + withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') { + try { + sh """docker network create ${testNetwork}""" + sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\ + ${imageDindSSH} dockerd -H tcp://0.0.0.0:2375 + """ + sh """docker run --rm \\ + --name ${testContainerName} \\ + -e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\ + -e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\ + --network ${testNetwork} \\ + --volumes-from ${dindContainerName} \\ + -v ~/.docker/config.json:/root/.docker/config.json \\ + ${testImage} \\ + py.test -v -rxs --cov=docker --ignore=tests/ssh tests/ + """ + sh """docker stop ${dindContainerName}""" + // start DIND container with SSH + sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\ + ${imageDindSSH} dockerd --experimental""" + sh """docker exec ${dindContainerName} sh -c /usr/sbin/sshd """ + // run SSH tests only + sh """docker run --rm \\ + --name ${testContainerName} \\ + -e "DOCKER_HOST=ssh://${dindContainerName}:22" \\ + -e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\ + --network ${testNetwork} \\ + --volumes-from ${dindContainerName} \\ + -v ~/.docker/config.json:/root/.docker/config.json \\ + ${testImage} \\ + py.test -v -rxs --cov=docker tests/ssh + """ + } finally { + sh """ + docker stop ${dindContainerName} + docker network rm ${testNetwork} + """ + } } } } |