Repository name component must match "[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*"

Hey folks,

I’m struggling with some circle ci deployments. I keep getting an error when I run the following commands. I’ve tried using tick marks “`” as well to surround some of the nested commands but to no avail; same error.

It makes it to the second-to-last command and fails.

docker tag example/api:$CIRCLE_SHA1 $ECR/example/api:$CIRCLE_BRANCH
repository name component must match "[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*"

docker tag example/api:$CIRCLE_SHA1 $ECR/example/api:$CIRCLE_BRANCH returned exit code 1

Action failed: docker tag example/api:$CIRCLE_SHA1 $ECR/example/api:$CIRCLE_BRANCH

circle.yml

machine:
  timezone:
    America/Denver
  ruby:
    version: 2.3.1
  services:
    - redis
    - docker
deployment:
  hub:
    branch: develop
    commands:
      - docker build --rm=false -t example/api:$CIRCLE_SHA1 . | cat # workaround progress weirdness
      - DOCKER_LOGIN=$(aws ecr get-login --region us-west-2)
      - echo $DOCKER_LOGIN
      - $DOCKER_LOGIN
      - ECR=$(echo $DOCKER_LOGIN | sed 's|.*https://||')
      - echo "docker tag example/api:$CIRCLE_SHA1 $ECR/example/api:$CIRCLE_BRANCH"
      - docker tag example/api:$CIRCLE_SHA1 $ECR/example/api:$CIRCLE_BRANCH
      - docker push $ECR/example/api:$CIRCLE_BRANCH | cat # workaround progress weirdness

Hi,

I’m not sure about your entire circle.yml file but this line immediately caught my attention:

This won’t work because every command is ran in its own shell. The ECR variable won’t exist once that command finishes running. Have you see the AWS ECS/ECR doc that we have? It has some examples and links to an example repo that may help.

Ah! That makes sense, thank you! I ended up moving all the commands into it’s own build.sh script and just calling that from circle.yml.

I’m happy to hear you got everything working. =)