schmmd
schmmd

Reputation: 19478

Add credentials to allow Travis-CI to use a private Nexus repository

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

Upvotes: 5

Views: 1931

Answers (2)

Christopher Currie
Christopher Currie

Reputation: 3065

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.

Upvotes: 4

Michael Pollmeier
Michael Pollmeier

Reputation: 1380

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?

Upvotes: 2

Related Questions