I'm using Travis for continuous integration. However, my projects depend on a private Nexus repository. I would rather not check in sbt credentials into our repository. Travis does support encryption keys but they only affect environment variables.
How can I get Travis to authenticate against Nexus? sbt
does not seem to support credentials from an environment variable.
https://github.com/sbt/sbt/blob/0.13/launch/src/main/scala/xsbt/boot/Update.scala#L56
There looks like there is support to specify a credentials file from an environment variable, or to specify credentials as system properties. Unfortunately, this didn't seem to work with 0.13
.
sbt -Dsbt.boot.realm="Sonatype Nexus Repository Manager" -Dsbt.boot.host="www.there.com" -Dsbt.boot.user="deployment" -Dsbt.boot.password="password" aether-deploy
You want to use Travis secure environment variables as documented. Assuming your environment variables are NEXUS_USER
and NEXUS_PASS
, the command line needs to be:
sbt 'set credentials += Credentials("Sonatype Nexus Repository Manager", "www.there.com", System.getenv("NEXUS_USER"), System.getenv("NEXUS_PASS"))' aether-deploy
You could also safely have that line in your build.sbt
, if you wanted to make that a standard practice for your builds.
The Jackson Scala Module uses this for deploying Travis builds to the Sonatype OSS repository. You can our .travis.yml
to see how it's set up.
You can set global variables in your .travis.yml as defined here: http://docs.travis-ci.com/user/build-configuration/#Set-environment-variables
Those global vars can be encrypted for travis using the travis gem. Explained e.g. here: How to use travis-ci's .travis.yml to provide environment parameters for Node.js Application?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With