I recently had to deal with the task of experimenting with automating the build and push of the Docker images, using Jenkins, to my company’s Google Cloud based container registry.
After hours of googling and reading plenty of articles here is the base solution I decided to apply.
The first thing I needed was make sure I had the following Jenkins’ plugins:
- Docker pipeline
- Google Container Registry Auth Plugin
- Google OAuth Plugin
After that, I set up the Google Cloud credentials for the user we created to use with Jenkins. Then I created a service account key in the credentials page (API Manager > Credentials) in the Google Cloud console. It will download you a json file with the crendetials.
The next step I did was adding the credentials I just downloaded to our Jenkins container. I opened the