How to add Bash script to cloudbuild deployment, job?

version 1

steps:- name: 'bash'  args: ['echo', 'I am running a bash command']

version 2

steps:
- name: 'gcr.io/cloud-builders/gcloud'  
- entrypoint: 'bash'  
- args:  
 - '-eEuo'  
 - 'pipefail'  
 - '-c'  
 - |-
   if (( $(date '+%-e') % 2 )); then  
       echo "today is an odd day"
    else
       echo "today is an odd day, with an even number"
    fi
- name: another example
        image: gcr.io/ubuntu:latest
        command: ["/bin/sh"]
        args: 
        - '-c'
        - |
          DB_PATH="mysql://${MASTER_DSN}"
          echo "hello world!"
        imagePullPolicy: Always    
        env:
        - name: MASTER_DSN

Another example

steps:  
- name: 'gcr.io/cloud-builders/curl'  
entrypoint: 'bash'  
args:  
- '-c'  
- |  
  PET="$$(curl -s https://pets.doingdevops.com/pet_flaky --max-time 10)"  
  while [ "$$PET" == "ERROR" ] ; do  
      echo "Error: API failed to respond with a pet! Try again..."  
      PET="$$(curl -s https://pets.doingdevops.com/pet_flaky --max-time 10)"  
  done
    
  echo "Success! $${PET}"

References

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: