Indrid
Indrid

Reputation: 1172

GCP CloudBuild Logs

How can I add a custom message to Cloud Build logs?

I've tried using the bash entrypoint with the Docker builder (for example) and echoing some strings, but they don't appear in the build logs. Is there a way to achieve this?

Upvotes: 0

Views: 233

Answers (1)

RJC
RJC

Reputation: 1338

Make sure that the builder image you're using has bash in it. I tested this code and replaced the gcloud builder with docker and it is working fine. Here's an example code:

steps:
- name: 'gcr.io/cloud-builders/docker'
  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

And here's the Logs:

enter image description here

Upvotes: 1

Related Questions