Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 471
schmmd Avatar asked Nov 16 '13 01:11

schmmd


2 Answers

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.

like image 83
Christopher Currie Avatar answered Oct 21 '22 11:10

Christopher Currie


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?

like image 2
Michael Pollmeier Avatar answered Oct 21 '22 10:10

Michael Pollmeier