0

I read everything in this post and multiple others but nothing is working... I cannot use Google Credentials to access my git Repo in Google Cloud Platform

I have Jenkins running in a Docker Container in Google Cloud Platform. I have Source Code in a Google Cloud Repository that I want to use for a Build.

On the Google Cloud Platform side I created a Service User, gave the User the following Roles:

  • Project Worker
  • Source-Repository Admin
  • Storageobject creator
  • ComputeEngine creator

I created the JSON File and downloaded it.

On The Jenkins Side I installed the Google OAuth Credentials and the Google Container Registry Auth Plugin.

I added new Credentials "Google Service Account from private key" and added the json file.

enter image description here

So, if I now want to create a new Job (Freestyle or pipeline does not matter) I see the following: enter image description here

I see the credentials I created but for the "Google Container Registry". As soon as I add the repository URL, "https://source.developers.google.com/p...." The Drop-down is cleared and all is gone.

I also took a look at the credentials.xml and job file, to see, if I can rewrite there something by myself. The Google Credentials do not have an credentialId like others...

<com.google.jenkins.plugins.credentials.oauth.GoogleRobotPrivateKeyCredentials plugin="google-oauth-plugin@0.6">
      <module/>
      <projectId>testprojekt</projectId>
      <serviceAccountConfig class="com.google.jenkins.plugins.credentials.oauth.JsonServiceAccountConfig">
        <jsonKeyFile>/var/jenkins_home/gauth/key8529180263669390055.json</jsonKeyFile>
      </serviceAccountConfig>
    </com.google.jenkins.plugins.credentials.oauth.GoogleRobotPrivateKeyCredentials>

I'm currently out of ideas... would be happy for any hint. Thank you!

Samuel N
  • 615
  • 5
  • 10
metabolic
  • 669
  • 1
  • 7
  • 24
  • Possible duplicate of [Jenkins with Google Cloud Source Repository](https://stackoverflow.com/questions/49650148/jenkins-with-google-cloud-source-repository) – Martin Zeitler Nov 17 '18 at 19:44
  • @MartinZeitler I also linked this post in my question, it is not a duplicate in my opinion. I do not see any credentials at all if i paste the url. The one in the mentioned question does see something. Another answer there references to the credendialId, which i do not have for the Google Private Key Authentication – metabolic Nov 17 '18 at 21:40
  • the service account might lack the required scopes, which subsequently may lead to it not being validated and therefore not appearing in the drop-down. see https://wiki.jenkins.io/display/JENKINS/Google+OAuth+Plugin (defining these scope in Jenkins is not sufficient to make them available; the service-account needs them assigned, as well). – Martin Zeitler Nov 24 '18 at 00:27
  • https://wiki.jenkins.io/display/JENKINS/Google+OAuth+Plugin?focusedCommentId=143494361#comment-143494361 – Samuel N Nov 27 '18 at 03:22
  • @metabolic, what workflow are you following for this? If you can link met to a documentation wit the step-by-steps I might be able to reproduce the failed authentication. Did you try enabling the correct API scopes as [Martin Zeitler](https://stackoverflow.com/users/549372/martin-zeitler) recommended? I think you could probably start there. – Samuel N Nov 27 '18 at 03:32
  • 1
    There's a [known issue](https://github.com/jenkinsci/google-oauth-plugin/issues/6) with the Google OAuth Plugin in Jenkins. You could try adding the JSON file containing your GCP credentials as a "Secret file" credential and use it like this in your pipeline: withCredentials([[$class: 'FileBinding', credentialsId: "my-credentials-id", variable: 'YOUR_GCP_CREDENTIALS']]). This was taken from [here](https://wiki.jenkins.io/display/JENKINS/Google+OAuth+Plugin?focusedCommentId=143494361#comment-143494361). – Samuel N Nov 27 '18 at 03:33
  • I am in the same boat, the plugin used to work, and now after refreshing my cluster facing the same issue, what approach did you follow to resolve this. – skjagini Dec 11 '19 at 15:58

0 Answers0