How to build release and publish a Spring Boot project using Gradle, GitLab CI and Docker?

Viewed 23

What I want should be relatively simple:

Prerequisites:

  • Spring Boot project with Gradle build file (already generated from start.spring.io)
  • version in gradle.properties, with snapshot suffix (ex: 1.0.1-SNAPSHOT)

In the Gitlab CI pipeline:

  • using

    ./gradlew clean build release publish

build the jar myapp-1.0.1.jar, and push it to the Gitlab package registry

  • extract the release version into a variable
  • build the Docker container with the released jar (not the SNAPSHOT)
  • tag the Docker container with the release version obtained before
  • push the Docker container to the Docker registry

I have the prerequisites. I can release the project and I get the non-snapshot jar, but when I try to publish, it publishes the SNAPSHOT jar (if the release was 1.0.1, 1.0.2-SNAPSHOT is the jar pushed to the registry).

I can push the Docker container to the registry, but not sure how to go about for the tagging.

0 Answers
Related