GitLab dependency resolution and artifact publishing for sbt.
This plugin requires sbt 1.5.0+ as it relies on Coursier and sbt.internal.CustomHTTP
Add the following to your project/plugins.sbt file:
addSbtPlugin("nl.zolotko.sbt" % "sbt-gitlab" % "0.0.8")
You can configure the plugin in your build.sbt file by overriding gitlabDomain
(default is "gitlab.com"
), and optionally
gitlabGroupId
/gitlabProjectId
, for example:
gitlabDomain := "gitlab.your-company.com"
// optionally,
gitlabProjectId := Some(GitlabProjectId("unicorn"))
// or
gitlabGroupId := Some(GitlabGroupId("ninjas"))
You can either put your credentials directly into build.sbt (not recommended):
gitlabCredentials := Some(GitlabCredentials(gitlabDomain.value, "Private-Token", "<ACCESS-TOKEN>"))
Or, keep them out of your source control:
~/.sbt/1.0/.credentials
realm=gitlab
host=gitlab.your-company.com
user=Private-Token
password=<ACCESS-TOKEN>
build.sbt or ~/.sbt/1.0/credentials.sbt
DefaultOptions.addCredentials
This plugin supports dependency resolution from multiple GitLab package repositories:
gitlabRepositories ++= Seq(
GitlabProjectRepository(gitlabDomain.value, GitlabProjectId("unicorn")),
GitlabGroupRepository(gitlabDomain.value, GitlabGroupId("ninjas"))
)
Utilizing the sbt publish command within GitLab CI/CD should require no additional configuration. This plugin automatically pulls the following GitLab environment variables which should always be provided by default within GitLab Pipelines
$CI_JOB_TOKEN # Access Token to authorize read/writes to the GitLab package registry
$CI_PROJECT_ID # Project ID for active project pipeline. Used so GitLab knows what project to publish the artifact under
$CI_GROUP_ID # GitLab Group ID. Used for fetching Artifacts published under the specified Group.
# In a pipeline this would be set to the id of the group the project is under (when applicable)
$CI_SERVER_HOST # The host name for GitLab defaults to gitlab.com
Run test
for regular unit tests (there are none at the moment).
Run scripted
for sbt script tests.
This plugin is a fork of gilcloud/sbt-gitlab.