Open matejcerny opened 6 months ago
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:
build.sbt
ThisBuild / resolvers ++= Registry.additionalResolvers ThisBuild / credentials += Registry.credentials ThisBuild / publishTo := Registry.publishToGitlab(37794088) // Gitlab project id
.sbt/.credentials:
.sbt/.credentials
realm=GitLab Packages Registry host=gitlab.com user=Private-Token password=<YOUR-TOKEN>
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.
For all the developers outhere, GitLab now supports sbt push/pull natively, see: https://gitlab.com/gitlab-org/gitlab/-/issues/408479
build.sbt
:.sbt/.credentials
: