bash - 无法使用 bash 脚本设置 gcloud 项目
问题描述
我基本上是在尝试通过调用 bash 脚本文件来设置谷歌项目 ID,但无法这样做。但是,如果我单独运行该命令,它就可以工作。我通过激活 gcloud shell 终端来调用 bash 脚本文件。
命令:./init.sh vibrant-brand-298097 vibrant-bucket terraform-trigger /var/dev/dev.tfvars
初始化.sh:
#!/bin/bash
PROJECT_ID=$1
#Bucket for storing state
BUCKET_NAME=$2
# Based on this value cloud build will set trigger on the test repository
TERRAFORM_TRIGGER=$3
# This is the path to the env vars file, terraform will pick variables from this path for the given env.
TERRAFORM_VAR_FILE_PATH=$4
#Check if all the args were passed
if [ $# -ne 4 ]; then
echo "Not all the argumets were passed"
exit 0
fi
echo "setting project to $PROJECT_ID"
gcloud config set project $PROJECT_ID
echo "Creating bucket $BUCKET_NAME"
gsutil mb -b on gs://$BUCKET_NAME/
错误日志:
setting project to
ERROR: (gcloud.config.set) argument VALUE: Must be specified.
Usage: gcloud config set SECTION/PROPERTY VALUE [optional flags]
optional flags may be --help | --installation
解决方案
推荐阅读
- arrays - 如何使用 Eratoshenes Sieve 在第 n 个素数中设置数组大小的上限?
- python - 如何编写函数以使用列表和整数作为参数返回列表元素
- javascript - Electron 无法读取我上传的未定义视频的属性“路径”
- julia - Julia 的反斜杠 (\) 运算符在两个矩阵上做了什么?
- java - 尝试使用资源为什么不能修改资源
- ansible - failed_when 在 ansible 中带有 msg
- regex - 如何使用正则表达式提取尴尬的浮点表示?
- android - 如何在后台事件中销毁 tablayout 片段?
- django - 在 Django 中再次随机化
- sql - SQL - 加入 3 个表并为每个 id 选择最新记录的条目