Skip to content

GitLab now supports sbt natively #41

Description

@matejcerny

For all the developers outhere, GitLab now supports sbt push/pull natively, see: https://gitlab.com/gitlab-org/gitlab/-/issues/408479

object Registry {
  val credentials: Credentials = sys.env
    .get("CI_JOB_TOKEN") // automatically generated token in the gitlab-ci
    .map(Credentials("GitLab Packages Registry", "gitlab.com", "gitlab-ci-token", _))
    .getOrElse(Credentials(Path.userHome / ".sbt" / ".credentials")) // for local development

  val additionalResolvers: Seq[MavenRepository] = Seq(
    "GitLab" at
      "https://gitlab.com/api/v4/projects/<PROJECT_ID>/packages/maven"
  )

  def publishToGitlab(projectId: Int): Option[MavenRepository] =
    Some("gitlab" at s"https://gitlab.com/api/v4/projects/$projectId/packages/maven")
}

build.sbt:

ThisBuild / resolvers ++= Registry.additionalResolvers
ThisBuild / credentials += Registry.credentials
ThisBuild / publishTo := Registry.publishToGitlab(37794088) // Gitlab project id

.sbt/.credentials:

realm=GitLab Packages Registry
host=gitlab.com
user=Private-Token
password=<YOUR-TOKEN>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions