Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker Golang和Gitlab持续集成_Docker_Go_Continuous Integration_Gitlab - Fatal编程技术网

Docker Golang和Gitlab持续集成

Docker Golang和Gitlab持续集成,docker,go,continuous-integration,gitlab,Docker,Go,Continuous Integration,Gitlab,我即将在Gitlab中使用Golang软件实现完整(无测试阶段)的连续集成 在Docker登录步骤中尝试构建Docker映像时失败 这是我的.gitlab ci.yml: stages: - build variables: REGISTRY: registry.gitlab.com GO_PROJECT: mysoftware build_golang_binary: image: golang:latest stage: build before_script:

我即将在Gitlab中使用Golang软件实现完整(无测试阶段)的连续集成

Docker登录
步骤中尝试构建Docker映像时失败

这是我的
.gitlab ci.yml

stages:
  - build

variables:
  REGISTRY: registry.gitlab.com
  GO_PROJECT: mysoftware

build_golang_binary:
  image: golang:latest
  stage: build
  before_script:
    - mkdir -p ${GOPATH}/src/${GO_PROJECT}
    - cp -r ${CI_PROJECT_DIR}/* ${GOPATH}/src/${GO_PROJECT}/
    - cd ${GOPATH}/src/${GO_PROJECT}
    - go get
  script:
    - cd ${GOPATH}/src/${GO_PROJECT}
    - go build

build_docker_image:
  image: docker:latest
  stage: build
  script:
    - docker login $REGISTRY
    - docker build --no-cache -t ${REGISTRY}/me/${GO_PROJECT} .
    - docker push ${REGISTRY}/me/${GO_PROJECT}

下面是我得到的错误:
$docker login$REGISTRY
错误:无法从非TTY设备执行交互式登录

我认为凭证将提供给此CI流程。。显然,他们不是


解决这个问题的最佳选择是什么?

我的回答假设您在CI和注册表中都使用GitLab.com(基于上面的
.GitLab CI.yml
示例中的
Registry.GitLab.com

您可以利用GitLab CI作业中提供的几个环境变量对GitLab注册表进行身份验证:

  • docker登录-u$CI\u注册表\u用户-p$CI\u注册表\u密码$CI\u注册表

$CI\u REGISTRY\u PASSWORD
是一种仅在工作期间有效的临时令牌。您可以在中了解更多信息。

我的回答假设您在CI和注册表中都使用GitLab.com(基于上面的
.GitLab.com
示例中的
REGISTRY.GitLab.com

您可以利用GitLab CI作业中提供的几个环境变量对GitLab注册表进行身份验证:

  • docker登录-u$CI\u注册表\u用户-p$CI\u注册表\u密码$CI\u注册表

$CI\u REGISTRY\u PASSWORD
是一个临时令牌,仅在您的工作期间有效。您可以在中了解更多信息。

这是我们的私有gitlab实例的工作原理;我假设它也适用于gitlab.com:
docker login-u gitlab CI token--PASSWORD stdin$REGISTRY这是我们私有gitlab实例的工作原理ce;我想它也适用于gitlab.com:
docker login-u gitlab ci token--password stdin$REGISTRY非常感谢,这就是我要搜索的!我应该找到可用环境变量的列表,这可能会有很大帮助…我也可以帮助:)-。如果这个答案有帮助,请接受我的答案。非常感谢,这就是我正在搜索的!我应该找到可用环境变量的列表,这可能会有很大帮助…我也可以帮助:)-。如果这个答案有帮助,请接受我的回答。