Platforms
GitLab

Basic example

See the following minimal example showing how to publish the jar task to GitLab:

publishMods {
    file = tasks.named("jar").flatMap { it.archiveFile }
    changelog = "Changelog"
    type = STABLE
    modLoaders.add("fabric")
 
    gitlab {
        accessToken = providers.environmentVariable("GITLAB_TOKEN")
        projectId = 12345678 // This is how GitLab resolves the project you are publishing to
        commitish = "main" // This is the branch the release tag will be created from
    }
}

Multiple releases

You can create multiple GitLab destinations by specifying a name like so:

publishMods {
    gitlab("A") {
            // Configure GitLab settings for project A here
    }
 
    gitlab("B") {
           // Configure GitLab settings for project B here
    }
}

This will create 2 separate GitLab releases.

Parent releases

If you wish to upload files to a GitLab release created by another task either in the same project or another subproject, you can use the parent option. This is useful where you have multiple subprojects that you want to publish to a single release, the following example shows how a root project can create the release and subprojects can upload files to it:

Root project

publishMods {
    gitlab {
        accessToken = providers.environmentVariable("GITLAB_TOKEN")
        commitish = "main"
        tagName = "TEST_TAG"
 
        // Allow the release to be initially created without any files.
        allowEmptyFiles = true
    }
}

Subproject

When using the parent option, only the accessToken and files are required, the other options are forcefully inherited from the parent task.

publishMods {
    gitlab {
        accessToken = providers.environmentVariable("GITLAB_TOKEN")
 
        // Specify the root project's gitlab task to upload files to
        parent project(":").tasks.named("publishGitlab")
    }
}

All options

See the following example showing all the GitLab specific options:

publishMods {
    gitlab {
        accessToken = providers.environmentVariable("GITLAB_TOKEN")
        commitish = "main"
        tagName = "TEST_TAG"
 
       // Optionally set the announcement title used by the Discord publisher
       announcementTitle = "Download from GitLab"
 
        // Upload the files to a previously created release, by providing another GitLab publish task
        // This is useful in multi-project builds where you want to publish multiple subprojects to a single release
        parent tasks.named("publishGitlab")
 
        // Optionally allow the release to be created without any attached files.
        // This is useful when you have subprojects using the parent option that you want to publish a single release.
        allowEmptyFiles = true
    }
}