gitlab-ci $CI_REGISTRY_IMAGE is not set
Summary
Maybe we are doing something wrong, but, already tried a lot to get this working and the $CI_REGISTRY_IMAGE environment variable is not being set when CI runs.
Steps to reproduce
Use the docker sample .gitlab-ci.yml file:
image: docker:latest
services:
- docker:dind
before_script:
- docker info
- export
build:
stage: build
script:
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker build --pull -t "$CI_REGISTRY_IMAGE:latest" .
- docker push "$CI_REGISTRY_IMAGE:latest"
The export
command on before_script does not show the CI_REGISTRY_IMAGE variable. Copied the portion where it should be set.
export CI_PROJECT_URL='http://gitlab.sample/group/sample'
export CI_REGISTRY='docker.sampleserver.net'
export CI_REGISTRY_PASSWORD='xxxxxxxxxxxxxxxxxxxx'
export CI_REGISTRY_USER='gitlab-ci-token'
export CI_REPOSITORY_URL='http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.sample/group/sample.git'
export CI_RUNNER_DESCRIPTION='Shared Runner'
What is the current bug behavior?
When running the build step it gives an error:
$ docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
Login Succeeded
$ docker build --pull -t "$CI_REGISTRY_IMAGE:latest" .
invalid argument ":latest" for t: invalid reference format
See 'docker build --help'.
ERROR: Job failed: exit code 125
What is the expected correct behavior?
It should set CI_REGISTRY_IMAGE
Output of checks
docker info:
$ docker info
WARNING: No swap limit support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.04.0-ce
Storage Driver: vfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary:
containerd version: 422e31ce907fd9c3833a38d7b8fdd023e5a76e73
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-62-generic
Operating System: Alpine Linux v3.5 (containerized)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 488.4MiB
Name: dab683fbc13e
ID: VVCA:N2CB:WYHK:IW6F:ICM7:S224:4TNR:OX75:2BM5:PW4P:3IZE:RWFG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Results of GitLab environment info
root@git:/etc/gitlab# sudo gitlab-rake gitlab:env:info
System information System: Ubuntu 14.04 Current User: git Using RVM: no Ruby Version: 2.3.3p222 Gem Version: 2.6.6 Bundler Version:1.13.7 Rake Version: 10.5.0 Redis Version: 3.2.5 Git Version: 2.10.2 Sidekiq Version:4.2.7
GitLab information Version: 9.0.5 Revision: a6b9899d Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://*********** HTTP Clone URL: http:///some-group/some-project.git SSH Clone URL: git@:some-group/some-project.git Using LDAP: yes Using Omniauth: no
GitLab Shell Version: 5.0.0 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/ Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
root@git:/etc/gitlab# sudo gitlab-rake gitlab:check SANITIZE=true Checking GitLab Shell ...
GitLab Shell version >= 5.0.0 ? ... OK (5.0.0) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 4/1 ... ok 10/4 ... ok 3/5 ... ok 12/14 ... ok 12/15 ... ok 12/16 ... ok 3/18 ... ok 10/19 ... ok 16/23 ... ok 12/24 ... ok 16/27 ... ok 17/30 ... ok 17/31 ... ok 18/32 ... ok 18/33 ... ok 18/34 ... ok 18/35 ... ok 20/43 ... ok 4/44 ... ok 16/45 ... ok 3/51 ... ok 23/52 ... ok 2/58 ... repository is empty 20/60 ... ok 3/61 ... ok 3/62 ... ok 24/63 ... ok 27/64 ... ok 27/65 ... ok 27/66 ... ok 27/67 ... ok 27/68 ... ok 27/69 ... ok 15/70 ... ok 15/71 ... ok 35/73 ... ok 35/74 ... ok 12/75 ... ok 12/76 ... ok 12/77 ... ok 37/78 ... ok 37/79 ... ok 37/80 ... ok 39/81 ... ok 15/82 ... ok 3/83 ... ok 2/84 ... ok 12/85 ... ok 3/86 ... ok 40/87 ... ok 40/88 ... ok 3/89 ... ok 3/90 ... ok 3/91 ... ok 3/92 ... ok 3/93 ... ok 41/94 ... ok 42/95 ... ok 18/96 ... ok 44/97 ... ok 45/98 ... ok 45/99 ... ok 45/100 ... ok 45/101 ... ok 45/102 ... ok 45/103 ... ok 45/104 ... ok 45/105 ... ok 45/106 ... ok 45/107 ... ok 45/108 ... ok 45/109 ... ok 45/110 ... ok 46/111 ... ok 4/112 ... ok 3/113 ... ok 2/114 ... ok 47/115 ... ok 27/116 ... ok 18/117 ... ok 3/118 ... repository is empty 48/120 ... ok 48/121 ... ok 48/122 ... ok 48/123 ... ok 48/124 ... ok 2/125 ... ok 12/126 ... ok 48/127 ... ok 48/128 ... ok 48/129 ... ok 4/130 ... ok 47/131 ... repository is empty 4/132 ... ok 45/133 ... ok 48/135 ... ok 40/136 ... ok 48/137 ... ok 51/138 ... ok 52/139 ... ok 4/140 ... ok 4/141 ... ok 4/142 ... ok 4/143 ... repository is empty 48/144 ... ok 45/145 ... ok 2/148 ... repository is empty Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Access to /var/opt/gitlab/.ssh/authorized_keys: OK Send ping to redis server: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) SANITIZED
Checking LDAP ... Finished
Checking GitLab ...
Git configured with autocrlf=input? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config outdated? ... no Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory setup correctly? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) projects have namespace: ... 4/1 ... yes 10/4 ... yes 3/5 ... yes 12/14 ... yes 12/15 ... yes 12/16 ... yes 3/18 ... yes 10/19 ... yes 16/23 ... yes 12/24 ... yes 16/27 ... yes 17/30 ... yes 17/31 ... yes 18/32 ... yes 18/33 ... yes 18/34 ... yes 18/35 ... yes 20/43 ... yes 4/44 ... yes 16/45 ... yes 3/51 ... yes 23/52 ... yes 2/58 ... yes 20/60 ... yes 3/61 ... yes 3/62 ... yes 24/63 ... yes 27/64 ... yes 27/65 ... yes 27/66 ... yes 27/67 ... yes 27/68 ... yes 27/69 ... yes 15/70 ... yes 15/71 ... yes 35/73 ... yes 35/74 ... yes 12/75 ... yes 12/76 ... yes 12/77 ... yes 37/78 ... yes 37/79 ... yes 37/80 ... yes 39/81 ... yes 15/82 ... yes 3/83 ... yes 2/84 ... yes 12/85 ... yes 3/86 ... yes 40/87 ... yes 40/88 ... yes 3/89 ... yes 3/90 ... yes 3/91 ... yes 3/92 ... yes 3/93 ... yes 41/94 ... yes 42/95 ... yes 18/96 ... yes 44/97 ... yes 45/98 ... yes 45/99 ... yes 45/100 ... yes 45/101 ... yes 45/102 ... yes 45/103 ... yes 45/104 ... yes 45/105 ... yes 45/106 ... yes 45/107 ... yes 45/108 ... yes 45/109 ... yes 45/110 ... yes 46/111 ... yes 4/112 ... yes 3/113 ... yes 2/114 ... yes 47/115 ... yes 27/116 ... yes 18/117 ... yes 3/118 ... yes 48/120 ... yes 48/121 ... yes 48/122 ... yes 48/123 ... yes 48/124 ... yes 2/125 ... yes 12/126 ... yes 48/127 ... yes 48/128 ... yes 48/129 ... yes 4/130 ... yes 47/131 ... yes 4/132 ... yes 45/133 ... yes 48/135 ... yes 40/136 ... yes 48/137 ... yes 51/138 ... yes 52/139 ... yes 4/140 ... yes 4/141 ... yes 4/142 ... yes 4/143 ... yes 48/144 ... yes 45/145 ... yes 2/148 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.1.0 ? ... yes (2.3.3) Your git bin path is "/opt/gitlab/embedded/bin/git" Git version >= 2.7.3 ? ... yes (2.10.2) Active users: 20
Checking GitLab ... Finished
Possible fixes
For the time being we solved the problem using:
docker build --pull -t "$CI_REGISTRY/$CI_PROJECT_PATH:latest" .
docker push "$CI_REGISTRY/$CI_PROJECT_PATH:latest"