5

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
schmmd
  • 18,650
  • 16
  • 58
  • 102
  • Are you sure that Travis CI is using the sbt 0.13 launcher? Remember, the launcher version does not necessarily correspond to the version of sbt that is actually launched. Theoretically, old launchers can launch new sbt versions, and vice-versa (although this does not always work). – Robin Green Nov 16 '13 at 07:51
  • You can detect the launcher version by running `--version` when launching. – jsuereth Nov 16 '13 at 19:54
  • @robin-green, no I'm not sure. However, I am sure I'm using 0.13 on my machine and it's not working there either. – schmmd Nov 17 '13 at 21:43

2 Answers2

4

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.

Christopher Currie
  • 3,025
  • 1
  • 29
  • 40
2

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?

Community
  • 1
  • 1
Michael Pollmeier
  • 1,370
  • 11
  • 20
  • We tried this and it was OK. We ended up checking in raw credentials and feeling bad about it. – schmmd Jan 23 '14 at 03:24