SBT plugin for settings the credentials needed to push to a binary repository
In order to be able to publish to any repository it generally requires you to provide credentials to that repository.
Traditionally sbt uses the ~/.ivy2/.credentials file for that.
It however requires some manual setup in the build.sbt file.
This plugin will automatically try to parse all files ending with .credentials in the path ~/.ivy2/ and also parse credentials from specific ENV/sys.props.
Using built in pipelines with e.g. Bitbucket or Github it is convenient to provide secrets via ENV vars.
This plugin will automatically create a single credential based on the existence of these ENV/sys.props.
All of the ENV/sys.props must be present, if not they are not taken into use.
- CREDENTIAL_REALM - E.g. 'Sonatype Nexus Repository Manager'
- CREDENTIAL_HOST - E.g. 'nexus.domain.com'
- CREDENTIAL_USER - E.g. 'some-user'
- CREDENTIAL_PASSWORD - E.g. 'oh-so-secret'
This plugin will automatically try to parse all files ending with .credentials in the path ~/.ivy2/.
The examples below are a fully working .credentials files.
Note the '.credentials' suffix of the name, apart from that they can be called anything.
e.g .credentials
#Local Nexus installation
realm=Sonatype Nexus Repository Manager
host=nexus.domain.com
user=some-user
password=oh-so-secret
e.g. artifactory.credentials
#Local Artifactory installation
realm=Artifactory Realm
host=artifactory.domain.net
user=yet-another-user
password=yet-another-psw
e.g. mvn-central.credentials
#Maven Central
realm=Sonatype Nexus Repository Manager
host=oss.sonatype.org
user=secret-agent
password=wont-tell-you
The plugin provided by this project is an auto-plugin so once added to the project it will automatically read all .credential files in ~/.ivy2/.
Simply add this to the plugins.sbt file:
addSbtPlugin("org.dmonix.sbt" % "sbt-credentials-settings-plugin" % "VERSION")
To test that the plugin reads you local credentials file and/or ENV's try the command
sbt 'show credentials'
It will print something like this, representing the list of all three credentials it found in the examples above.
[info] List(sbt.librarymanagement.ivy.DirectCredentials@66859669, sbt.librarymanagement.ivy.DirectCredentials@6e591c03, sbt.librarymanagement.ivy.DirectCredentials@7115d5af)
[