Skip to content

Commit c854aba

Browse files
author
aiordache
committed
Mount docker config to DIND containers for authentication
Signed-off-by: aiordache <[email protected]>
1 parent 2601142 commit c854aba

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

Jenkinsfile

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,41 +83,44 @@ def runTests = { Map settings ->
8383
def dindContainerName = "dpy-dind-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
8484
def testContainerName = "dpy-tests-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
8585
def testNetwork = "dpy-testnet-\$BUILD_NUMBER-\$EXECUTOR_NUMBER-${pythonVersion}-${dockerVersion}"
86-
try {
87-
sh """docker network create ${testNetwork}"""
88-
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
89-
${imageDindSSH} dockerd -H tcp://0.0.0.0:2375
90-
"""
91-
sh """docker run --rm \\
92-
--name ${testContainerName} \\
93-
-e "DOCKER_HOST=tcp://${dindContainerName}:2375" \\
94-
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
95-
--network ${testNetwork} \\
96-
--volumes-from ${dindContainerName} \\
97-
${testImage} \\
98-
py.test -v -rxs --cov=docker --ignore=tests/ssh tests/
99-
"""
100-
sh """docker stop ${dindContainerName}"""
101-
102-
// start DIND container with SSH
103-
sh """docker run --rm -d --name ${dindContainerName} -v /tmp --privileged --network ${testNetwork} \\
104-
${imageDindSSH} dockerd --experimental"""
105-
sh """docker exec ${dindContainerName} sh -c /usr/sbin/sshd """
106-
// run SSH tests only
107-
sh """docker run --rm \\
108-
--name ${testContainerName} \\
109-
-e "DOCKER_HOST=ssh://${dindContainerName}:22" \\
110-
-e 'DOCKER_TEST_API_VERSION=${apiVersion}' \\
111-
--network ${testNetwork} \\
112-
--volumes-from ${dindContainerName} \\
113-
${testImage} \\
114-
py.test -v -rxs --cov=docker tests/ssh
115-
"""
116-
} finally {
117-
sh """
118-
docker stop ${dindContainerName}
119-
docker network rm ${testNetwork}
120-
"""
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+
}
121124
}
122125
}
123126
}

0 commit comments

Comments
 (0)