Jenkins on GCE - Deploying Google Cloud Function to different GCP project

20 views
Skip to first unread message

Boris Teplitsky

unread,
Mar 31, 2020, 6:57:11 AM3/31/20
to Jenkins Users

I have Jenkins installed on GCE VM (Debian) on project xxxx.

I need to deploy a cloud function with source in Google cloud repository to project yyyy.

I do it successfully from the shell of Jenkins VM. In order to deploy a function from pipeline I did follow:

  1. Create a service account in yyyy project.

  2. Upload the key (json file) to VM.


  3. Define pipeline:

  4. pipeline {

        agent any
    
        stages {
    
            stage('Build') {
    
                steps {
    
                    sh 'gcloud auth activate-service-account yyy...@yyyy.iam.gservice account.com --key-file jenkins-test.json'
    
                    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/
    
                    '''
    I have no access to the source repository in the project xxxx. OperationError: code=7, message=Failed to retrieve function source code.
    
Reply all
Reply to author
Forward
0 new messages