I’m experimenting with Jenkins and I’m starting to like it. In this page, I’m going to demonstrate how to configure Jenkins to build docker image and push it to my registry automatically.
What you’ll need:
- A git repository storing the Dockerfile
- A docker registry to push the image to
- A machine with Jenkins installed
- Jenkins needs the git and Docker plugins
On Jenkins console, create a project. For example, amzn2-awscli2. In the Source Code Management section, configure Jenkins to pull from my git repo. In this example, the repo is on https://xpk.headdesk.me/git/xpk/amzn2-awscli2.git and it’s public so no credential required.
In the build trigger section, enable Build periodically and tell Jenkins to perform the build weekly. The dockerfile itself does not change frequently. Otherwise a git webhook would be preferred. I still want the build to happen regularly to keep my awscli current.
In the build section, tell Jenkins where to push the image and what to name it. In this case, it’s registry.one27.cf/amzn2-awscli2
Finally, in the Post-build section, tell Jenkins to clean up the workspace after build.
Click build now in this project and after a few minutes, the image is built and pushed to my registry.
It’s a minimalist demonstration. I’m still learning about Jenkins. Comments are welcomed.
101 total views, 2 views today