Gitlab-ci for gradle 7.3.3

Hi,

I am boostratpping new springboot application with JDK 17 and gradle 7.3.3
I am trying to create ci/cd pipeline as well with gitlab-ci.yml
I want to first build and package application into docker image. For that below is my yaml file

image: docker:latest
services:
  - docker:dind

stages:
  - build
  - package

build:
  image: 7.3.3-jdk17-alpine
  stage: build
  only:
    refs:
      - master
      - development
  script:
    - ./gradlew clean build -x test
  artifacts:
    paths:
      - build/libs/*.jar

package:
  stage: package
  only:
    refs:
      - master
      - development
  script:
    - docker build -t registry.docke.com/imageName .
    - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD registry.docker.com
    - docker push registry.docker.com/imageName

I am getting below exception

022-01-22T13:18:44.825510189Z time="2022-01-22T13:18:44.825351332Z" level=info msg="API listen on [::]:2375"
2022-01-22T13:18:44.825726058Z time="2022-01-22T13:18:44.825654979Z" level=info msg="API listen on /var/run/docker.sock"
*********
Pulling docker image 7.3.3-jdk17-alpine ...
WARNING: Failed to pull image with policy "always": Error response from daemon: pull access denied for 7.3.3-jdk17-alpine, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:203:0s)
ERROR: Job failed: failed to pull image "7.3.3-jdk17-alpine" with specified policies [always]: Error response from daemon: pull access denied for 7.3.3-jdk17-alpine, repository does not exist or may require 'docker login': denied: requested access to the resource is denied (manager.go:203:0s)```

It seems like it cant download image and it needed docker credentials. But I think docker:dind service should have access to docker hub ? Please educate me if I am wrong.

Hi,

I think that repository does not exist is the problem, not the login. I tried a quick docker search 7.3.3-jdk17-alpine and it returns nothing. Are you sure that the image name starts with the version number? Usually, the image name syntax is user-or-group/project-distribution:versiontag.

Looking at gradle on Docker Hub I assume you want to specify it like this: gradle:7.3.3-jdk17-alpine following the syntax project-name:version-tag.

Test on the CLI works:

docker pull gradle:7.3.3-jdk17-alpine
7.3.3-jdk17-alpine: Pulling from library/gradle
59bf1c3509f3: Already exists
1f7418fdfb53: Pull complete
926adebbf5f6: Downloading [========>                                          ]  33.88MB/191.9MB
e0fb9f484b7d: Download complete
f5972d06d1cc: Download complete
7c3233c2e13d: Downloading [===========>                                       ]   7.94MB/35.41MB
10b84a439334: Downloading [======>                                            ]  15.58MB/115.8MB

Cheers,
Michael

1 Like

Hi Michael,

Thank you so much for the quick reply with correct answer.
Thats the fix, it went through fine when I updated image.

Regards
Ratna

1 Like