How to Push Docker Image to Google Container Registry (GCR) through Jenkins Job

Nilesh Suryavanshi
Google Cloud - Community
2 min readJun 10, 2017

I am assuming that you have running Container Engine cluster and deploy Jenkins as POD on Container Engine cluster.

Step 1) Install required Jenkins Plugins

Google OAuth Credentials Plugin

Docker Pipeline Plugin

Google Container Registry Auth Plugin

Step 2) Create a service account.

Attach Roles : Storage ->Storage Admin & Storage Object Viewer

Create Service Account key in json format. Downloaded key keep it safe we will be requiring in further configuration.

Step 3) We have to Add Global Credential

Jenkins -> Credentials -> Global Credentials -> Add Credentials

Select kind : Google Service Account from private key

Provide Project Name(which can be any thing) and click on JSON key radio button and attach json file which we already downloaded in Step 2.

Step 4) Under Jenkins Project -> Configure -> Build -> Select ‘Docker Build and Publish’

Required fields :

Repository Name (Give your Google Container Repository name): <project-id or project-name>/sample-php-app

Tag : ${BUILD_NUMBER}

Docker registry URL (If your Repository location is US): https://us.gcr.io

Registry Credentials (Project Name provided while add global credential in Step 3 : <Project Name> Google Container Registry Account

` Lets try it out!!!!!!!

--

--

Nilesh Suryavanshi
Google Cloud - Community

@nilesh7756 | VMware NSX-T | Kubernetes | Openshift | PCF/PKS | Docker | AWS | GCE/GKE | DevOps