且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Jenkins 管道中使用 Google 服务帐户进行身份验证

更新时间:2023-12-03 09:55:04

您需要将您的服务帐户 JSON 文件上传为 秘密文件.那么:

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