Shippable CI UI显示以下错误:
错误:检测到1个验证错误:'[if [ develop == master ]; then xxx-xx-prod; else xxx-xx-dev; fi]'
处的值'environmentNames'
未能满足约束:成员必须满足约束:[成员的长度必须小于或等于40,成员的长度必须大于或等于4]
这是我的shippable.yml文件:
branches:
only:
- develop
- master
build:
ci:
- "echo 'CI is running'"
post_ci:
- "docker build -t=\"xxxx/xxx-xxxx:$BRANCH.$BUILD_NUMBER\" ."
- "docker push xxxx/xxx-xxx:$BRANCH.$BUILD_NUMBER"
- "pip install --upgrade botocore"
- "pip install setuptools==34.0.1"
integrations:
deploy:
-
application_name: seamless-ai
env_name: if [ "$BRANCH" == "master" ]; then "xxx-xx-prod"; else "xxx-xx-dev"; fi
image_name: xxxx/xxx-xxx
image_tag: $BRANCH.$BUILD_NUMBER
integrationName: AWS-int
region: us-east-1
type: aws
hub:
-
integrationName: "Docker Hub"
type: docker
language: node_js
基本上,我的问题如下:
env_name: if [ "$BRANCH" == "master" ]; then "xxx-xx-prod"; else "xxx-xx-dev"; fi
基本上我需要做的是:
如果分支是主分支,则env_name
必须为xxx-xx-prod
,然后env_name
= xxx-xx-dev
如何解决此问题?
答案 0 :(得分:1)
由于我们看到$BRANCH
在值内被评估,因此可能的解决方案是将其写入env变量,然后只需替换它。
这可以通过将此行添加到post-ci
:
- if [ "$BRANCH" == "master" ]; then export ENV_NAME="xxx-xx-prod"; else export ENV_NAME="xxx-xx-dev"; fi
然后在deploy
:
env_name: $ENV_NAME
我不知道这是否真的有用。