-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Jenkinsfile with docker registry credentials #2705
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 \\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better watched in diff mode without white space changes. |
||
${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} | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use an unprivileged account, and no access to any private images in the docker namespaces? ideally a PAT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just compared it to the docker/compose repo and used the same here. 😅
And this pipeline also pushes the images. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a better hub account that we could use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if needed, we could create one perhaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's currently pushing; what credentials does it use for that?
(sorry for brevity; on my phone 😂)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the Jenkins secret to use a PAT instead of the real password.