Home > Net >  How can I specify the app deployment to be in another folder using cloud build?
How can I specify the app deployment to be in another folder using cloud build?

Time:10-28

I have my app in a folder called client, how can I create a trigger that will specify the app deployment workflow to execute on that folder instead?

My cloudbuild.yaml file is also in that folder and has this content:

steps:
- name: "gcr.io/cloud-builders/gcloud"
  args:
    - |
      cd ../client
      gcloud app deploy
timeout: "1600s"

The error is as such:

ERROR: (gcloud) Invalid choice: 'cd ../client

My file directory:

  • main
    • .gitignore
    • LICENSE
    • README.md
    • client
      • app.yaml
      • cloudbuild.yaml

CodePudding user response:

If you want to manually execute the directory change then you need to change your entry point to bash. Take a look at the second example here: https://cloud.google.com/build/docs/configuring-builds/run-bash-scripts

The gcloud tool will also take a parameter for which app.yaml to deploy so you could just add the desired path to your existing args. You can find the gcloud app deploy reference here: https://cloud.google.com/sdk/gcloud/reference/app/deploy

CodePudding user response:

gcloud is not bash or similar, then you cannot execute something like cd ../client

I'd suggest to use dir in your step, then it will use the directory specified as the working directory:

steps:
- name: "gcr.io/cloud-builders/gcloud"
  dir: client/
  args:
    - app
    - deploy
timeout: "1600s"

You can change the path, just be aware about the full structure of your files.

  • Related