【发布时间】:2019-10-26 11:28:42
【问题描述】:
我有一个服务器,我们的测试用例在其中运行所有 API,它位于 GCP 的计算引擎上。如何从云构建 CI/CD 管道连接它,以便 CI/CD 阶段仅传递来自服务器的 200 响应状态代码?
GCP 说要创建一个自定义构建步骤 (here)。文档不是很清楚
【问题讨论】:
标签: google-cloud-platform continuous-integration google-cloud-build
我有一个服务器,我们的测试用例在其中运行所有 API,它位于 GCP 的计算引擎上。如何从云构建 CI/CD 管道连接它,以便 CI/CD 阶段仅传递来自服务器的 200 响应状态代码?
GCP 说要创建一个自定义构建步骤 (here)。文档不是很清楚
【问题讨论】:
标签: google-cloud-platform continuous-integration google-cloud-build
您有 2 个解决方案。
ENTRYPOINT 完成它,它将在 Cloud Build 管道中调用steps:
- name: gcr.io/cloud-builders/gcloud
entrypoint: "bash"
args:
- "-c"
- |
RESPONSE=$(curl -i <YOUR URL> | grep HTTP | cut -d' ' -f2)
if [ "200" != "$$RESPONSE" ]; then exit 1; fi
注意双重 $$ 以防止 Cloud Build 查看替换变量
【讨论】:
gcr.io/cloud-builders/curl,但您必须保留入口点。实际上,如果您直接使用 curl 图像,您将执行一元调用。在这里,您需要执行调用并测试 HTTP 响应。因此,您需要一个脚本,从而将 bash 作为入口点