Search code examples
google-cloud-platformgoogle-cloud-functionsgoogle-cloud-buildcloudbuild.yaml

--source in cloudbuild.yaml


I have my current Cloud Build working, I connect my github repo to trigger the Cloud Build when I push to the main branch which then creates my Cloud Function, but I am confused about the the --source flag. I have read the google cloud function docs. They state that the minimal source repository URL is: https://source.developers.google.com/projects/${PROJECT}/repos/${REPO}. If I were to input this into my cloudbuild.yaml file, does this mean that I am mimicking the complete path of my github url? I am currently just using . which I believe is just the entire root directory.

my cloudbuild.yaml file:

steps:
  - name: "gcr.io/cloud-builders/gcloud"
    id: "deploypokedex"
    args:
      - functions
      - deploy
      - my_pokedex_function
      - --source=.
      - --entry-point=get_pokemon
      - --trigger-topic=pokedex
      - --timeout=540s
      - --runtime=python39
      - --region=us-central1

Solution

  • Yes you are mimicking the complete path of the Github URL. --source=. means that you are calling the source code in your current working directory. You can check this link on how to configure the Cloud Build deployment.

    Also based on the documentation you provided,

    If you do not specify the --source flag:

    • The current directory will be used for new function deployments.
    • If the function was previously deployed using a local filesystem path, then the function's source code will be updated using the current directory.
    • If the function was previously deployed using a Google Cloud Storage location or a source repository, then the function's source code will not be updated.

    Let me know if you have questions or clarifications.