Search code examples
scalasbtsbt-native-packager

Send module version as command line argument to SBT


I am using TeamCity to run a bash script that is utilizing SBT Native Packager to publish an image to Docker. The sbt portion of the bash script looks something like this:

sbt -DdockerRepository=$repo -DpackageName=$packageName -D myproject/docker:publish

I want to pass on the TeamCity build number as a version number to my package. Today I specify the version number manually in settings in build.sbt:

settings(
  version := "0.20",
  ....,
  dockerBaseImage := "example.com:5000/linux/java8:latest",
  dockerRepository in Docker := Some("example.com/myoldrepo"),
  dockerUpdateLatest := true'
)

I want to be able to do it like this:

activator -Dversion=0.21 -DpackageName=myproject -D myproject/docker:publish

but this does not seem to work. Yet overriding the dockerRepository like I do above is working.

How can I pass my desired version number into SBT from the command line/TeamCity?


Solution

  • You could set version before publish:

    sbt 'set version := "1.0"' docker:publish