How to authenticate with a Google Service Account in Jenkins pipeline

后端 未结 2 584

I want to use gcloud in Jenkins pipeline and therefore I have to authenticate first with the Google Service account. I\'m using the https://wiki.jenkins.io/display/

相关标签:
2条回答
  • 2021-02-08 08:53

    I couldn't get the 'Google Service Account from private key' working, but using the 'Secret File' type of credential in Jenkins, and uploaded my google service account JSON works.

    0 讨论(0)
  • 2021-02-08 09:10

    You need to upload your Sevice Account JSON file as a secret file. Then:

    withCredentials([file(credentialsId: 'key-sa', variable: 'GC_KEY')]) {
        sh("gcloud auth activate-service-account --key-file=${GC_KEY}")
        sh("gcloud container clusters get-credentials prod --zone northamerica-northeast1-a --project ${project}")
      }
    
    0 讨论(0)
提交回复
热议问题