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:
Create a service account in yyyy project.
Upload the key (json file) to VM.
Define pipeline:
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.