Search code examples
jenkinsgoogle-cloud-platformjenkins-pluginsgoogle-container-registry

Connect Jenkins to GCP container registry


I'm trying to connect jenkins to container registry on GCP. I follow some examples but I'm blocked on a simple and stupid thing.

I have this stage in my jenkins file :

    stage('Push image') {
      docker.withRegistry('https://eu.gcr.io', 'gcr:[my-credentials]') {
        app.push("${env.BUILD_NUMBER}")
        app.push("latest")
      }
}

But I don't have any idea which credential put there...

I try to create on GCP -> API&Service -> Credentials -> Create Credential -> Service Account Key

Download the json and add it to Jenkins, on piplene field I use: name of project, credential id, and so on, but it doesn't work.


Solution

  • At the end I found a solution.

    • First of all you have to stop the Instance.
    • Open the instance settings
    • Edit the Instance
    • At the end of the list of settings change the Cloud API access Scopes : give access to the resource that you need.

    enter image description here