I have a CloudBuild cloudbuild.yaml
file which defines a task to export a GCE Image to a Bucket in .vmdk
format.
gcloud compute images export \
--image=$IMAGE_NAME \
--destination-uri=$DESTINATION_BUCKET/$VMDK_NAME \
--export-format=vmdk \
--network=$NETWORK \
--subnet=$SUBNET \
--project=$PROJECT_ID \
--async
The gcloud compute images export
is working fine; the command triggers a child CloudBuild to convert and to upload to gcs.
There are no fields in the new build that identifies the "parent" caller, these fields are empty:
Provider
, Source
, Ref Commit
, Trigger Id
, Trigger Type
, Trigger Name
, Trigger Description
How can I identify these child process ?
Interesting question.
I think you may be unable to do this (see Hack below) because there's no user-definable metadata that you can pass from the parent Cloud Build task through the gcloud compute images export ...
to the child Cloud Build task.
Hack I've not tried this! It may (!?) be possible to inject a trace token from Cloud Build into the step that invokes
gcloud compute images export
command using the--trace-token
flag. You could try (I've not tried this) setting this flag ongcloud compute images export ... --trace-token=${SOMETHING}
perhaps using the value of the parent's Cloud Build ID? This should be passed through subsequent API calls and hopefully at least reaches as far the child Cloud Build.
I think it's a useful feature request to be able to pass arbitrary metadata (labels?) through Cloud SDK commands. You should consider submitting a request to Google's Issue Tracker for Cloud SDK