【发布时间】:2019-06-13 22:22:18
【问题描述】:
我有一个预提交挂钩设置来运行 Google Cloud Storage api 的测试套件。我可以模拟 Google Build 并很好地运行测试cloud-build-local --config=cloudbuild.yaml --dryrun=false .。但是,在运行预提交挂钩时,我收到错误
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
google_cloud_api.py 函数示例
def list_blobs(bucket_name):
"""Returns list of names of all the blobs in the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blobs = bucket.list_blobs()
return [blob.name for blob in blobs]
test_google_cloud_api.py 函数示例
def test_get_all_files():
blobs = google_cloud_storage_api.list_blobs(GCS_BUCKET_NAME)
for blob in blobs:
print(blob)
【问题讨论】:
-
如何运行预提交挂钩?
-
@CloudAce 通过使用
pre-commit-config.yaml
标签: google-cloud-platform google-cloud-storage pytest google-cloud-build