User1
User1

Reputation: 41213

How to make GitLab CI Release a Spring Boot JAR using gradle?

I have a Spring Boot project that builds using a bootJar task in gradle. It produces a runnable ____-1.0-SNAPSHOT.jar file. Now, I want to leverage GitLab CI to build the JAR and make releases.

There didn't seem to be an obvious way to do the builds. I started looking at the researchgate gradle plugin. It seems promising but has a lot of assumptions.

What is the best way to get the release JARs out of GitLab CI?

Upvotes: 2

Views: 4983

Answers (2)

Joseph Orlando
Joseph Orlando

Reputation: 183

Ruwanka provided a great answer, however I believe it is now a bit outdated. GitLab.com (and self-hosted) now supports hosted maven repositories as a native feature of their Premium tiers.

More information regarding how to deploy a java application (JAR, etc.) for private or public consumption can be found here:

https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#gitlab-maven-repository-premium

Upvotes: 0

Ruwanka De Silva
Ruwanka De Silva

Reputation: 3755

There is couple of ways of getting released artifacts from gitlab ci pipeline.

  1. Publish it to maven repository (private repository if it is propitiatory)
  2. use gitlab job artifact functionality within pipeline so you can download it via gitlab web interface
  3. build docker image from your pipeline and upload it to docker registry from pipeline

Here is the sample .gitlab-ci.yml which uses gitlab job artifacts functionality (assume gradle wrapper is used)

image: java:8-jdk

cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches

build:
  stage: build
  script:
    - ./gradlew assemble
  # define path to collect artifacts
  artifacts:
    paths:
      - build/libs/*.jar
    expire_in: 1 week
  only:
    - master

Upvotes: 1

Related Questions