How to authenticate with a Google Service Account in Jenkins pipeline

后端 未结 2 590

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 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}")
      }
    

提交回复
热议问题