使用linux .sh脚本自动选择prompt



我正在尝试使用CircleCI来自动推送到google容器注册表,并启动kubernetes pod的滚动更新。我有一个circle.yml文件,其依赖关系如下:

dependencies:
  cache_directories:
    - ~/kubernetes
    - ./google-cloud-sdk
  pre:
    - chmod a+x ./download-gcloud.sh ./install-kubernetes.sh ./deploy.sh
    - ./download-gcloud.sh
    - ./google-cloud-sdk/install.sh <--- This step hangs
    - ./google-cloud-sdk/bin/gcloud components update
    - ./google-cloud-sdk/bin/gcloud auth activate-service-account $GCLOUD_CLIENT_ID --key-file ./kubernetes/gcloud_pem.p12
    - ./install-kubernetes.sh

我可以拉下tar文件并安装它,但我不确定如何选择提示符,所以构建挂起:

Welcome to the Google Cloud SDK!
To help improve the quality of this product, we collect anonymized data on how
the SDK is used. You may choose to opt out of this collection now (by choosing
'N' at the below prompt), or at any time in the future by running the following
command:
gcloud config set --scope=user disable_usage_reporting true
Do you want to help improve the Google Cloud SDK (Y/n)?

是否有一个标志,我可以设置时,运行安装脚本禁用提示?

建议采用非交互方式安装Cloud SDK,设置环境变量CLOUDSDK_CORE_DISABLE_PROMPTS:

export CLOUDSDK_CORE_DISABLE_PROMPTS=1

这将使Cloud SDK以非交互模式运行,在这种模式下,它接受所有提示符的默认值。这既适用于安装,也适用于一般操作(这对编写脚本很有用)。

要使其永久保存,请运行

gcloud config set core/disable_prompts 1

一旦安装了Cloud SDK

您是否尝试将-q传递给gcloud?我们在kubernetes中运行端到端测试时这样做,以抑制交互提示。

最新更新