Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitLab now supports sbt natively #41

Open
matejcerny opened this issue Mar 7, 2024 · 1 comment
Open

GitLab now supports sbt natively #41

matejcerny opened this issue Mar 7, 2024 · 1 comment

Comments

@matejcerny
Copy link

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>
@thereisnospoon
Copy link

Does this work for self-hosted Gitlab instances though?
We were not able to use this in such case so we use the plugin instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants