简体   繁体   中英

Automatically select prompt using linux .sh script

I am trying to use CircleCI to automate my push to the google container registry and initiate a rolling update of the kubernetes pods. I have a circle.yml file with dependencies like this:

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

I can pull the tar file down and install it, but I am not sure how to select a prompt, so the build hangs:

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)?

Is there a flag I can set when running the install script to disable prompts?

The recommended way to install the Cloud SDK non-interactively is to set the environment variable CLOUDSDK_CORE_DISABLE_PROMPTS :

export CLOUDSDK_CORE_DISABLE_PROMPTS=1

This will make the Cloud SDK run in non-interactive mode, in which it accepts the default value for all prompts. This applies both to installation and general operation (which will be useful for scripting).

To make this permanent, run

gcloud config set core/disable_prompts 1

once the Cloud SDK is installed.

Have you tried passing -q to gcloud? We do this while running e2e tests in kubernetes to suppress the interactive prompts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM