firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.15k stars 125 forks source link

Cannot perform an interactive login from a non TTY device #1105

Closed david-nano closed 6 months ago

david-nano commented 6 months ago

Minimal .gitlab-ci.yml illustrating the issue

---
Build system CPU:
  stage: build
  image: docker:24.0.2-git
  tags:
  - k8s-2c4m
  services:
  - name: registry.hub.docker.com/library/docker:24.0.2-dind
    alias: docker
  before_script:
  - docker login -u ${_USER} -p ${_PASS} ${DOCKER_TEMP_REGISTRY}
  script:
  - docker build --rm -f ${DOCKERFILE} 

Expected behavior Get docker login working properly

Host information Ubuntu 20.04 gitlab-ci-local 4.46.1

Containerd binary docker

Additional context The error log we are facing:

user@user-ThinkPad-P14s-Gen-2a:~/repos/system$ gcl --artifacts-to-source false  --stage build --cwd .
parsing and downloads finished in 79 ms
Build system CPU              starting docker:24.0.2-git (build)
Build system CPU              copied to docker volumes in 799 ms
Build system CPU              started service image: registry.hub.docker.com/library/docker:24.0.2-dind with aliases: registry.hub.docker.com-library-docker, registry.hub.docker.com__library__docker, docker in 332 ms
Build system CPU              service image: registry.hub.docker.com/library/docker:24.0.2-dind healthcheck passed in 1.69 s
Build system CPU              artifacts from UnitIATestIAsystem was empty
Build system CPU              imported artifacts in 26 ms
Build system CPU              $ docker login -u ${CUBINARY_USER} -p ${CUBINARY_PASS} ${DOCKER_TEMP_CUBINARY_REGISTRY}
Build system CPU              > Error: Cannot perform an interactive login from a non TTY device
Build system CPU              finished in 3.91 s  FAIL 1  
Build system CPU              !! no artifacts was copied !!

 FAIL  Build system CPU             
  > Error: Cannot perform an interactive login from a non TTY device
pipeline finished in 5.32 s

We added .gitlab-ci-local-env as needed:

PRIVILEGED=true
ULIMIT=8000:16000
VOLUME="/etc/docker/daemon.json:/etc/docker/daemon.json certs:/certs/client"
VARIABLE="DOCKER_TLS_CERTDIR=/certs DOCKER_BUILDKIT=0 COMPOSE_DOCKER_CLI_BUILD=0"
DOCKER_OPTS="--config-file=/etc/docker/daemon.json"
firecow commented 6 months ago

Does this actually work on a "real" gitlab-runner?

Can you echo the $_PASS and make sure it ain't empty? I pretty sure its empty.

david-nano commented 6 months ago

Yes, it's working on my laptop, but not on my friend laptop (the content of the issue is my friend logs)

firecow commented 6 months ago

Does it actually work on gitlab.com runners?

Is the $_PASS variables value empty or undefined?

Idangor commented 6 months ago

Does it actually work on gitlab.com runners?

Is the $_PASS variables value empty or undefined?

Hi, It runs on on-prem gitlab with kubernetes gitlab runner. Should work locally as well. all variables are defined.

david-nano commented 6 months ago

Does it actually work on gitlab.com runners?

Is the $_PASS variables value empty or undefined?

We don't use gitlab.com, only self-hosted instance. The variables provided in $HOME/.gitlab-ci-local/variables.yml file, and readable in the steps before. As @Idangor described.

david-nano commented 6 months ago

Some how now it's working, without any changes.