Gitlab dependency resolution and artifact publishing for sbt
addSbtPlugin("com.gilcloud" % "sbt-gitlab" % "0.0.6") // in your project/plugins.sbt file
This plugin requires sbt 1.0.0+
This plugin also supports dependency resolution from private gitlab package repositories, to use this you need to which to ivy for dependency resolution rather than the now default coursier as this plugin overrides the handler for ivy. This can be done for example by adding.
ThisBuild / useCoursier := false
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 pakcage 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 Groupt 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
Any of these 'defaults' can be overwritten in your build.sbt file
import com.gilcloud.sbt.gitlab.{GitlabCredentials,GitlabPlugin}
GitlabPlugin.autoImport.gitlabGroupId := Some(12345)
GitlabPlugin.autoImport.gitlabProjectId := Some(12345)
GitlabPlugin.autoImport.gitlabDomain := "my-gitlab-host.com"
GitlabPlugin.autoImport.GitlabCredentials := Some(GitlabCredentials("Private-Token","<API-KEY>"))
// Alternatively for credential managment
// ideal for pulling artifacts locally and keeping tokens out of your source control
// see below for sample .credentials file
credentials += Credentials(Path.userHome / ".sbt" / ".credentials.gitlab"),
~/.sbt/.credentials.gitlab
realm=gitlab
host=my-git-lab-host
user=Private-Token
password=<API-KEY>
In order to publish to
Run test
for regular unit tests.
Run scripted
for sbt script tests.
- publish your source to GitHub
- create a bintray account and set up bintray credentials
- create a bintray repository
sbt-plugins
- update your bintray publishing settings in
build.sbt
sbt publish
- request inclusion in sbt-plugin-releases
- Add your plugin to the community plugins list
- Claim your project an Scaladex