我正在使用ecr orb构建并将映像推送到注册表,但是由于某些原因,circle env var在构建过程中不可用。
这是我的config.yml
(我已注释掉一些故障排除步骤)
version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@3.1.0
aws-ecs: circleci/aws-ecs@0.0.8
jobs:
build:
docker:
- image: circleci/python:3.7
steps:
- checkout
- restore_cache:
keys:
- cache-{{ checksum "Pipfile.lock" }}
- cache-
- run:
name: Install dependencies
command: pipenv sync --dev
- save_cache:
key: cache-{{ checksum "Pipfile.lock" }}
paths:
- ~/.local
- ~/.cache
- run:
name: 'Lint Flake8'
command: pipenv run flake8
# - run:
# name: 'Test'
# command: |
# ENVIRONMENT=development pipenv run python src/manage.py test --noinput
workflows:
build-and-deploy:
jobs:
- build
- aws-ecr/build_and_push_image:
account-url: AWS_ECR_ACCOUNT_URL
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
repo: "dev-portal"
region: AWS_DEFAULT_REGION
tag: "${CIRCLE_SHA1}"
requires:
- build
filters:
branches:
only: circleci/aws-ecs-deploy
# - aws-ecs/deploy-service-update:
# requires:
# - aws-ecr/build_and_push_image
# filters:
# branches:
# only: circleci/aws-ecs-deploy
# aws-region: AWS_DEFAULT_REGION
# family: "${AWS_RESOURCE_NAME_PREFIX}-service"
# cluster-name: "${AWS_RESOURCE_NAME_PREFIX}-cluster"
# container-image-name-updates: "container=${AWS_RESOURCE_NAME_PREFIX}-service,image-and-tag=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/nginx-portal:${CIRCLE_SHA1}"
# verify-revision-is-deployed: true
# post-steps:
# - run:
# name: Test the deployment
# command: |
# TARGET_GROUP_ARN=$(aws ecs describe-services --cluster ${AWS_RESOURCE_NAME_PREFIX}-cluster --services ${AWS_RESOURCE_NAME_PREFIX}-service | jq -r '.services[0].loadBalancers[0].targetGroupArn')
# ELB_ARN=$(aws elbv2 describe-target-groups --target-group-arns $TARGET_GROUP_ARN | jq -r '.TargetGroups[0].LoadBalancerArns[0]')
# ELB_DNS_NAME=$(aws elbv2 describe-load-balancers --load-balancer-arns $ELB_ARN | jq -r '.LoadBalancers[0].DNSName')
我对Orbs上下文/ circleci的环境变量不了解什么?
谢谢大家!