Reputation: 9956
We are using Cloud Build on Google Cloud Platform.
Is it possible to add a timestamp to every line of the log output?
Upvotes: 4
Views: 1587
Reputation: 4278
The solution in @Methkal Khalawi's comment above works out of the box: instead of looking at CloudBuild Logs within the CloudBuild tab of the GCP Console which look like this:
... open the Logging (Stack Driver) tab and select Cloud Build from the dropdown box. This will show you the same logs you'd see in the Cloud Build tab, but now with timestamps, like this:
Upvotes: 5
Reputation: 2477
you cannot do this with Cloud Build directly but you can workaround by using moreutils package on linux:
gcloud builds submit --config cloudbuild.yaml | ts '[%Y-%m-%d %H:%M:%S]'
This will give you an output like:
[2020-04-08 10:53:53] starting build "50e00fbb-2224-46d4-b13a-6b15a9fbbe3c"
[2020-04-08 10:53:53]
[2020-04-08 10:53:53] FETCHSOURCE
[2020-04-08 10:53:53] Fetching storage object xxxxxxx
[2020-04-08 10:53:53] Copying xxxxxx
/ [1 files][ 331.0 B/ 331.0 B]
[2020-04-08 10:53:53] Operation completed over 1 objects/331.0 B.
[2020-04-08 10:53:53] BUILD
[2020-04-08 10:53:53] Starting Step #0
[2020-04-08 10:53:53] Step #0: Pulling image: ubuntu
[2020-04-08 10:53:53] Step #0: Using default tag: latest
[2020-04-08 10:53:53] Step #0: latest: Pulling from library/ubuntu
[2020-04-08 10:53:53] Step #0: Digest: xxxxxxx
[2020-04-08 10:53:53] Step #0: Status: Downloaded newer image for ubuntu:latest
[2020-04-08 10:53:53] Step #0: docker.io/library/ubuntu:latest
Upvotes: 2