Environment variables aren't rendering

docker
circle.yml

#1

I have the following config…

version: 2
jobs:
  build:
    environment:
      GCLOUD_PROJECT_NAME: tabb-168314
      GCLOUD_CLUSTER_NAME: dev
      CLOUDSDK_COMPUTE_ZONE: europe-west1-b
      DOCKER_TAG_PREFIX: eu.gcr.io/$GCLOUD_PROJECT_NAME/menu-api
      DOCKER_TAG: $DOCKER_TAG_PREFIX:$CIRCLE_SHA1
      GOOGLE_APPLICATION_CREDENTIALS: $HOME/gcloud-service-key.json
      CLOUDSDK_CORE_DISABLE_PROMPTS: 1
    docker:
      - image: circleci/golang:1.9
    working_directory: /go/src/github.com/TabbDrinkLTD/menu-api
    steps:
      - checkout
      - run:
          name: Go build
          command: go build -o menu-api
      - run:
          name: Go test
          command: go test -v
      - deploy:
          name: Update Gcloud components
          command: |
            echo "$DOCKER_TAG"
            curl https://sdk.cloud.google.com | bash
            sudo ~/google-cloud-sdk/bin/gcloud --quiet components update --version 149.0.0
            sudo ~/google-cloud-sdk/bin/gcloud --quiet components update --version 149.0.0 kubectl
            echo $GCLOUD_SERVICE_KEY | base64 --decode -i > ${HOME}/gcloud-service-key.json
            sudo ~/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
            sudo ~/google-cloud-sdk/bin/gcloud config set project $GCLOUD_PROJECT_NAME
            sudo ~/google-cloud-sdk/bin/gcloud --quiet config set container/cluster $GCLOUD_CLUSTER_NAME
            sudo ~/google-cloud-sdk/bin/gcloud config set compute/zone $CLOUDSDK_COMPUTE_ZONE
            sudo ~/google-cloud-sdk/bin/gcloud --quiet container clusters get-credentials $GCLOUD_CLUSTER_NAME
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              docker build -t $DOCKER_TAG .
              docker tag $DOCKER_TAG $DOCKER_TAG_PREFIX:latest
              sudo ~/google-cloud-sdk/bin/gcloud docker -- push $DOCKER_TAG
              sudo ~/google-cloud-sdk/bin/gcloud docker -- push $DOCKER_TAG_PREFIX:latest
              kubectl --namespace=production patch deployment menu-api -p '{"spec":{"template":{"spec":{"containers":[{"name":"menu-api","image":"'"${DOCKER_TAG}"'"}]}}}}'
            fi
            if [ "${CIRCLE_BRANCH}" == "develop" ]; then
              docker build -t $DOCKER_TAG .
              docker tag $DOCKER_TAG $DOCKER_TAG_PREFIX:develop
              sudo ~/google-cloud-sdk/bin/gcloud docker -- push $DOCKER_TAG"
              sudo ~/google-cloud-sdk/bin/gcloud docker -- push $DOCKER_TAG_PREFIX:develop
              kubectl --namespace=staging patch deployment menu-api -p '{"spec":{"template":{"spec":{"containers":[{"name":"menu-api","image":"'"${DOCKER_TAG}"'"}]}}}}'
            fi

However none of the environment variables defined in the top part of the config seem to output within the command under deploy?

Cheers,

Ewan


#2

Hi @EwanValentine,

I think it’s not implemented yet. Follow and vote at this post.

A workaround is to run

docker build -t $(eval echo ${DOCKER_TAG_PREFIX}) .


#3

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.