This code generated an error for me : TypeError: create_build() takes from 1 to 2 positional arguments but 3 were given
Try with this code :
# from datetime import timedelta
from google.cloud.devtools import cloudbuild_v1
# build = {"steps": [{"name": "ubuntu","args": ["sleep", "100"],}],}
build = {'steps': [{'name': 'gcr.io/cloud-builders/docker','args': ['version'], 'id': 'Docker Version'}],}
client = cloudbuild_v1.CloudBuildClient()
response = client.create_build(project_id="YOUR-GCP-PROJECT-ID",build=cloudbuild_v1.Build(build),)
print(response)
Original code found here: https://github.com/googleapis/python-cloudbuild/issues/30