如果我使用环境变量 circle.yml 波纹管,失败,但如果我静态键入机器名称,它将起作用。
如何在 CircleCI 中正确引用环境变量?
version: 2
executorType: machine
stages:
build:
workDir: ~/app
enviroment:
- IMAGE_NAME: "nginx-ks8-circleci-hello-world"
# - AWS_REGISTER: "096957576271.dkr.ecr.us-east-1.amazonaws.com"
steps:
- type: checkout
- type: shell
name: Build the Docker image
shell: /bin/bash
command: |
docker build --rm=false -t $IMAGE_NAME .
我用这个 circleci 文档的例子检查你的语法 https://circleci.com/docs/2.0/language-python/#config-walkthrough 所以你必须删除 hiphen
enviroment:
IMAGE_NAME: "nginx-ks8-circleci-hello-world"
针对 CircleCi 2.0 的 docker 映像中的环境变量。
Circle 在子 shell 中运行每个命令,因此无法从构建本身为 CircleCi 构建设置环境变量。
而是使用实际的 CircleCi 环境变量:https://circleci.com/gh/{yourOrganization}/{yourRepo}/edit#env-vars