0

I want to automate the deployment of Cloud Function in to Production project through Cloud Build whose source files are present in Cloud Source Repository of DEV project. How can I ensure that the moment I push the code in production branch of Cloud Source Repository of DEV project, the Cloud Function gets created in to Production Project .

Nibrass H
  • 2,403
  • 1
  • 8
  • 14
  • 2
    Check out this documentation: https://cloud.google.com/cloud-build/docs/deploying-builds/deploy-functions#continuous_deployment can work for you? – Claudio Mar 17 '20 at 19:54
  • Hi Claudio, This link is generic. When you will actually try to implement the scenario ,then u will know that while creating the trigger in project-PROD,it will not show the repository which you created in project-DEV. Hence you will not be able to refer the repo which you created in DEV project. – SUNDARAM SRIVASTAVA Mar 17 '20 at 23:34

2 Answers2

0

I think my answer will help here: How to pass API parameters to GCP cloud build triggers

Basically what Claudio recommended, use the examples to build your steps. I believe what you want to do is create a step that the. Triggers the cloud function when you push changes to the dev production branch. When the trigger is called and ran, you then add a step to either run the cloud function or use the REST API to trigger the build by its ID. See my example above.

Lance Sandino
  • 316
  • 1
  • 4
0

If I understand, you are trying to trigger a build from a repository stored on another project.

This is not possible, the build triggers must be on the same project than the repositories

Jan Hernandez
  • 4,414
  • 2
  • 12
  • 18
  • You understood it very correct. I am trying to trigger a build from a repo stored on another project. Just to clarify it more:- Is it not possible to pass the name of target project Id in which I'm supposed to build the cloud function through cloudbuild.yaml or while running the command : gcloud builds submit I can pass it as parameters. BTW I have already tried sending like this: --project=$project_id..But this is trying to GET the cloud function instead of POST it on target project-id. – SUNDARAM SRIVASTAVA Mar 19 '20 at 11:13
  • i think that is not possible reach another project in a custom step, using the gcloud image, but maybe it could works if you manually mount a generic Docker image in an step and install gcloud sdk inside and try to deploy your code in the another project but maybe is easier create a repo on the prod project – Jan Hernandez Mar 19 '20 at 15:13