使用文件circle.yml
文件构建docker镜像时,我试图传递一个环境变量$CIRCLE_PROJECT_USERNAME
,以便该文件不是特定于项目的。不幸的是,使用标记参数-t
构建的Docker失败了:
docker build -t CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:$CIRCLE_BRANCH . returned exit code 1
repository name component must match "[a-z0-9]+(?:[._-][a-z0-9]+)*" Action failed: docker build -t CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:$CIRCLE_BRANCH .
Circle.yml
档案
machine:
environment:
services:
- docker
dependencies:
override:
- docker info
- docker build -t CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:$CIRCLE_BRANCH .
test:
override:
- docker run -d $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:$CIRCLE_BRANCH
deployment:
hub:
branch: master
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD
- docker push $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:$CIRCLE_BRANCH
deployment:
hub:
branch: develop
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD
- docker push $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:$CIRCLE_BRANCH
答案 0 :(得分:3)
应该工作,检查env是否实际设置并且只包含允许的字符:
[a-z0-9]+(?:[._-][a-z0-9]+)*
编辑:
docker build -t CIRCLE_PROJECT_USERNAME ...
也许只是错过$
? ;)