首页 > 解决方案 > GCE 上的 Jenkins - 将 Google Cloud Function 部署到不同的 GCP 项目

问题描述

我在项目 xxxx 的 GCE VM (Debian) 上安装了 Jenkins。

我需要在谷歌云存储库中部署一个带有源的云功能来项目 yyyy。

我从 Jenkins VM 的外壳成功地做到了。为了从管道部署功能,我确实遵循了:

  1. 在 yyyy 项目中创建服务帐户。

  2. 将密钥(json 文件)上传到 VM。

  3. 激活账户 gcloud auth activate-service-account yyyy-sa@yyyy.iam.gservice account.com --key-file jenkins-test.json

  4. 定义管道:

    管道{

        agent any
    
        stages {
    
            stage('Build') {
    
                steps {
    
                    sh 'gcloud config set account yyyy@yyyy.iam.gserviceaccount.com'
    
                    sh '''
    gcloud functions deploy helloWorld --region=us-central1 --runtime nodejs8 --trigger-http --project yyyy \
      --source https://source.developers.google.com/projects/xxxx/repos/test1/moveable-aliases/master/paths/HelloWorld/
    
                    '''
    
                }
    
            }
    
        }
    
    }
    

无论如何,我收到:

    gcloud functions deploy helloWorld --region=us-central1 --runtime nodejs8 --trigger-http
 --project yyyy --source https://source.developers.google.com/projects/xxxx/repos/test1/moveable- 
 aliases/master/paths/HelloWorld/
    ERROR: (gcloud.functions.deploy) Your current active account [yyyy@yyyy.iam.gserviceaccount.com] **does not have any valid credentials**

标签: jenkinsgoogle-cloud-platformgoogle-cloud-functions

解决方案


推荐阅读