Skip to content

Commit 4328197

Browse files
authored
Merge pull request #2705 from aiordache/jenkins_dockerhub_creds
Update Jenkinsfile with docker registry credentials
2 parents 5b471d4 + c854aba commit 4328197

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

Jenkinsfile

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ def buildImages = { ->
2525
imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}"
2626
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"
2727
imageDindSSH = "${imageNameBase}:sshdind-${gitCommit()}"
28-
29-
buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "")
30-
buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
31-
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7")
28+
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
29+
buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "")
30+
buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
31+
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7")
32+
}
3233
}
3334
}
3435
}
@@ -82,41 +83,44 @@ def runTests = { Map settings ->
8283
def dindContainerName = "dpy-dind-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
8384
def testContainerName = "dpy-tests-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
8485
def testNetwork = "dpy-testnet-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
85-
try {
86-
sh """docker network create ${testNetwork}"""
87-
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
88-
${imageDindSSH} dockerd -H tcp://0.0.0.0:2375
89-
"""
90-
sh """docker run --rm \\
91-
--name ${testContainerName} \\
92-
-e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\
93-
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
94-
--network ${testNetwork} \\
95-
--volumes-from ${dindContainerName} \\
96-
${testImage} \\
97-
py.test -v -rxs --cov=docker --ignore=tests/ssh tests/
98-
"""
99-
sh """docker stop ${dindContainerName}"""
100-
101-
// start DIND container with SSH
102-
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
103-
${imageDindSSH} dockerd --experimental"""
104-
sh """docker exec ${dindContainerName} sh -c /usr/sbin/sshd """
105-
// run SSH tests only
106-
sh """docker run --rm \\
107-
--name ${testContainerName} \\
108-
-e "DOCKER_HOST=ssh://${dindContainerName}:22" \\
109-
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
110-
--network ${testNetwork} \\
111-
--volumes-from ${dindContainerName} \\
112-
${testImage} \\
113-
py.test -v -rxs --cov=docker tests/ssh
114-
"""
115-
} finally {
116-
sh """
117-
docker stop ${dindContainerName}
118-
docker network rm ${testNetwork}
119-
"""
86+
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
87+
try {
88+
sh """docker network create ${testNetwork}"""
89+
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
90+
${imageDindSSH} dockerd -H tcp://0.0.0.0:2375
91+
"""
92+
sh """docker run --rm \\
93+
--name ${testContainerName} \\
94+
-e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\
95+
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
96+
--network ${testNetwork} \\
97+
--volumes-from ${dindContainerName} \\
98+
-v ~/.docker/config.json:/root/.docker/config.json \\
99+
${testImage} \\
100+
py.test -v -rxs --cov=docker --ignore=tests/ssh tests/
101+
"""
102+
sh """docker stop ${dindContainerName}"""
103+
// start DIND container with SSH
104+
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
105+
${imageDindSSH} dockerd --experimental"""
106+
sh """docker exec ${dindContainerName} sh -c /usr/sbin/sshd """
107+
// run SSH tests only
108+
sh """docker run --rm \\
109+
--name ${testContainerName} \\
110+
-e "DOCKER_HOST=ssh://${dindContainerName}:22" \\
111+
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
112+
--network ${testNetwork} \\
113+
--volumes-from ${dindContainerName} \\
114+
-v ~/.docker/config.json:/root/.docker/config.json \\
115+
${testImage} \\
116+
py.test -v -rxs --cov=docker tests/ssh
117+
"""
118+
} finally {
119+
sh """
120+
docker stop ${dindContainerName}
121+
docker network rm ${testNetwork}
122+
"""
123+
}
120124
}
121125
}
122126
}

0 commit comments

Comments
 (0)