Quarkus JGit

The Quarkus JGit extension enables the use of Eclipse JGit in a native executable.

Configuration

Once you have your Quarkus project configured you can add the jgit extension to your project by running the following command in your project base directory:

./mvnw quarkus:add-extension -Dextensions="jgit"

This will add the following to your pom.xml:

<dependency>
    <groupId>io.quarkiverse.jgit</groupId>
    <artifactId>quarkus-jgit</artifactId>
    <version>3.3.3</version>
</dependency>

Usage

The JGit dependency is resolved transitively when the extension is added to your project. Here is an example using it in a JAX-RS endpoint:

    @GET
    @Path("/clone")
    @Produces(MediaType.TEXT_PLAIN)
    public String cloneRepository(@QueryParam("url") String url) throws Exception {
        File tmpDir = Files.createTempDirectory("tmpgit").toFile();
        try (Git git = Git.cloneRepository().setDirectory(tmpDir).setURI(url).call()) {
            return tmpDir.toString();
        }
    }

When building a native executable, make sure that the SSL support is configured appropriately.

DevServices

JGit starts a Gitea server for testing purposes. The server is disabled by default when running tests. To enable it, set the quarkus.jgit.devservices.enabled configuration property to true.

An admin user is created with the following credentials:

  • Username: quarkus

  • Password: quarkus

Configuration properties

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

Whether devservice is enabled.

Environment variable: QUARKUS_JGIT_DEVSERVICES_ENABLED

boolean

false

If logs should be shown from the Gitea container.

Environment variable: QUARKUS_JGIT_DEVSERVICES_SHOW_LOGS

boolean

false

The exposed HTTP port for the Gitea container. If not specified, it will pick a random port

Environment variable: QUARKUS_JGIT_DEVSERVICES_HTTP_PORT

int

The Admin username for the Gitea container.

Environment variable: QUARKUS_JGIT_DEVSERVICES_ADMIN_USERNAME

string

quarkus

The Admin password for the Gitea container.

Environment variable: QUARKUS_JGIT_DEVSERVICES_ADMIN_PASSWORD

string

quarkus

The organization to be created when the Dev Service starts.

Environment variable: QUARKUS_JGIT_DEVSERVICES_ORGANIZATIONS

list of string

Repositories to be created when the Dev Service starts. A repository may optionally include an organization reference. For example, "my-org/my-repo" will create a repository named "my-repo" in the "my-org" organization. The organization will be created if missing. If no organization is specified, the repository will be created as a user repository.

Environment variable: QUARKUS_JGIT_DEVSERVICES_REPOSITORIES

list of string

${quarkus.application.name}

Should the container be reused?

Environment variable: QUARKUS_JGIT_DEVSERVICES_REUSE

boolean

false

The network alias for the container. Other containers in the same network can use this alias to connect to this container.

Environment variable: QUARKUS_JGIT_DEVSERVICES_NETWORK_ALIAS

string

The HTTP URL of the dev services. Generated once the service is up and running.

Environment variable: QUARKUS_JGIT_DEVSERVICES_HTTP_URL

URI