Gitlab-runner 本地构建 - 从非 TTY 设备登录 [英] Gitlab-runner local build - login from non TTY device

查看:22
本文介绍了Gitlab-runner 本地构建 - 从非 TTY 设备登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Linux 上使用 gitlab-runner 在本地构建我的项目.

I'm trying to build my project locally using gitlab-runner on Linux.

docker-build:
  stage: build
  image: docker:latest
  script:
    - docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY # user "gitlab-ci-token" is automatically created by GitLab
    - docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" target/
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"

不幸的是,我的尝试以关于docker login"无法从非 TTY 设备执行交互式登录的错误结束.

Unfortunately my attempts end with error about "docker login" not being able to perform interactive login from non-TTY device.

$ gitlab-ci-multi-runner exec docker --docker-privileged docker-build
Running with gitlab-ci-multi-runner 1.11.1 (a67a225)
  on  ()
Using Docker executor with image docker:latest ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Waiting for services to be up and running...
Pulling docker image docker:latest ...
Running on runner--project-1-concurrent-0 via vanqyard...
Cloning repository...
Cloning into '/builds/project-1'...
done.
Checking out 70187b2d as docker-basic-conf...
Skipping Git submodules setup
Checking cache for docker-build/docker-basic-conf...
Successfully extracted cache
$ docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
Error: Cannot perform an interactive login from a non TTY device
ERROR: Job failed: exit code 1
FATAL: exit code 1 

我的问题是有没有人偶然发现这个问题以及如何成功地执行构建?

My question is has anybody stumbled upon this issue and how to succesfunlly perform build?

推荐答案

可能与这里的问题无关,但有些人在尝试从类似 Linux 的 docker login 时可能会遇到完全相同的消息Windows 上的终端,例如 Git bashDocker 快速启动终端 甚至 Cygwin.

Probably not linked to the problem here, but some people might encounter the exact same message when trying a docker login from a Linux like terminal on Windows such as Git bash or Docker quickstart terminal or even Cygwin.

这里的技巧是使用 winpty docker login

这篇关于Gitlab-runner 本地构建 - 从非 TTY 设备登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆