Publish docker image in private registry.gitlab.com

148 Views Asked by At

How can I configure .gitlab-ci.yml in order to automatically publish an image in a gitlab docker private registry?

The relevant parte of my build.gradle script are:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.0'
}

...

tasks.named("bootBuildImage") {
    imageName.set("registry.gitlab.com/garanteasy/${project.name}")
    tags.add("registry.gitlab.com/garanteasy/${project.name}:${version}")
    pullPolicy = 'IF_NOT_PRESENT'
    publish = true
    docker {
        publishRegistry {
            if (project.hasProperty("token")) {
                token = project.getProperty("token")
            }
        }
    }
}

and .gitlab-ci.yml is

image: gradle:alpine
services:
  - name: docker:dind
    # explicitly disable tls to avoid docker startup interruption
    command: ["--tls=false"]
deploy:
  stage: deploy
  script: gradle -Puser=gitlab-ci-token -Ptoken=$CI_JOB_TOKEN bootBuildImage

I catch in the output a HTTP status 404

0

There are 0 best solutions below