【发布时间】:2020-10-21 07:05:03
【问题描述】:
下面是我的 buildspec.yaml 文件,用于列出 ecr 中的图像,我正在使用 to for 循环以及查找特定 imageId 的 elese 条件是否存在
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
commands:
- echo test
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
build:
commands:
- aws ecr list-images --repository-name mytestecrrepo > ecr.json
- cat ecr.json
- for imageTag in $(jq -r '.imageIds[].imageTag' < ecr.json); do
if [ $imageTag = "1.0" ]; then
echo "value exists"
else
echo "value doesntexists"
fi
done
post_build:
commands:
- echo Build completed on `date`
由于某种原因,代码构建抛出以下错误
/codebuild/output/tmp/script.sh:第 9 行:语法错误:文件意外结束
我在 shell 脚本中做错了什么?
【问题讨论】:
标签: bash amazon-web-services shell jq aws-codebuild