= GitLab CI

You can setup a link:https://docs.gitlab.com/ee/ci/README.html[GitLab CI] job as well.

NOTE: If you're already building with either Maven or Gradle then you might use the
xref:tools:jreleaser-maven.adoc[] or the xref:tools:jreleaser-gradle.adoc[] instead.

[source,yaml]
[subs="+macros"]
..gitlab-ci.yml
----
# Define a build step
build:
  # Specify an image that contains Java
  # Alternatively you may use a maven image if
  # your project does not rely on the Maven wrapper
  image: azul/zulu-openjdk:11
  # Bind to `build` stage
  stage: build
  # Full build
  script:
    - ./mvnw --batch-mode verify
  # Save artifacts for release
  artifacts:
    paths:
      - target/distributions/app/*.zip

# Create a release
release:
  # Use the predefined JReleaser Docker image
  image: jreleaser/jreleaser-slim:<version>
  # Bind to `deploy` stage
  stage: deploy
  # Set environment variables accordingly
  variables:
    JRELEASER_PROJECT_VERSION: 1.0.0
    JRELEASER_GPG_PASSPHRASE: $GPG_PASSPHRASE
    JRELEASER_GPG_PUBLIC_KEY: $GPG_PUBLIC_KEY
    JRELEASER_GPG_SECRET_KEY: $GPG_SECRET_KEY
    JRELEASER_GITLAB_TOKEN: $GL_PAT
    # Disable shallow cloning so that JReleaser can diff between tags
    # to generate a changelog
    GIT_DEPTH: 0
  # icon:rocket[] Execute JReleaser
  script:
    - jreleaser full-release
----

TIP: You may use `latest` to pull the latest stable release or `early-access` to pull the latest snapshot.

There is more than one jreleaser image available. Available images are listed xref:tools:jreleaser-docker.adoc[here].

