Indrid
Indrid

Reputation: 1172

run gcloud script in cloud build

I would like to have a cloud source repo which contains:-

Is it possible to set things up where on a push to that repo, cloud build runs the shell script? Is there an example of this anywhere? The only examples I can find are for Python or Node.js

Thanks

Upvotes: 1

Views: 1500

Answers (1)

CaioT
CaioT

Reputation: 2211

It's totally possible to run shell scripts within your cloud build pipeline.

Here you can find a few examples: https://cloud.google.com/build/docs/configuring-builds/run-bash-scripts

Within Cloud Build, there is also a built in gcloud image where you could directly run gcloud commands. Simple examples:

steps:
- name: gcr.io/cloud-builders/gcloud
  args: ['compute', 'instances', 'add-metadata', 'example-instance','--metadata startup-script-url=gs://bucket/file']
- name: 'gcr.io/cloud-builders/gcloud'
  args: [
        'deployment-manager',
        'deployments',
        'create', 
        'lgwm-$SHORT_SHA', 
        '--template', 
        'vm_template.jinja',
        '--properties',
        'zone:${_ZONE}'
        ]

Upvotes: 3

Related Questions