diff options
author | Anca Iordache <aiordache@users.noreply.github.com> | 2020-11-20 09:54:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-20 09:54:51 +0100 |
commit | 432819766014ce396e7507c52246ff5c8a11cdbc (patch) | |
tree | 512cb4a0b92ba2b61a999ca1289f16f3c281502f | |
parent | 5b471d44821e4a0018c57dffb46835c611d2cf82 (diff) | |
parent | c854aba15e14cdb6b84f34770e0ee8398f54b393 (diff) | |
download | docker-py-432819766014ce396e7507c52246ff5c8a11cdbc.tar.gz |
Merge pull request #2705 from aiordache/jenkins_dockerhub_creds
Update Jenkinsfile with docker registry credentials
-rw-r--r-- | Jenkinsfile | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/Jenkinsfile b/Jenkinsfile index fc716d8..4f97077 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,10 +25,11 @@ def buildImages = { -> imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}" imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}" imageDindSSH = "${imageNameBase}:sshdind-${gitCommit()}" - - buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "") - buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7") - buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7") + withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') { + buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "") + buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7") + buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7") + } } } } @@ -82,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} + """ + } } } } |